I'm learning how to use implicit intents along with intent filters, and have so far been unable to get the correct activity to fire. The code that is used to fire the intent is:
intent = new Intent();
intent.setAction("com.appsculture.intent.action.PLUGIN_RECEIVER");
startActivity(intent);
And the Intent filter for the desired activity is:
<activity android:name="PluginReceiver">
<intent-filter>
<action android:name="com.appsculture.intent.action.PLUGIN_RECEIVER"></action>
</intent-filter>
</activity>
The error I get is the standard ActivityNotFound
09-04 17:15:27.827: ERROR/AndroidRuntime(2552): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.appsculture.intent.action.PLUGIN_RECEIVER }
Solution: Simply addeded the android.intent.category.DEFAULT category to the intent filter
Works like a charm after that
For this, Open the MainActivity file and instantiate the component (Button) created in the XML file using the findViewById() method. This method binds the created object to the UI Components with the help of the assigned ID.
Implicit Intent with URI data Uri number = Uri. parse("tel:11061991"); Intent callIntent = new Intent(Intent. ACTION_DIAL, number);
Implicit Intents do not directly specify the Android components which should be called, it only specifies action to be performed. A Uri can be used with the implicit intent to specify the data type. Intent intent = new Intent(ACTION_VIEW,Uri.
For example, you might start a new activity within your app in response to a user action, or start a service to download a file in the background. Implicit intents do not name a specific component, but instead declare a general action to perform, which allows a component from another app to handle it.
I managed to solve this by simply adding the android.intent.category.DEFAULT category to the intent filter. Works like a charm after that.
As Commonsware has indicated in a comment on his answer, a category is required for Activities, though not for services or broadcast receivers.
Everything you have there should be fine, though I'd use new Intent("com.appsculture.intent.action.PLUGIN_RECEIVER")
, and the use of RECEIVER
seems like an odd piece of an action name for an Activity
instead of a BroadcastReceiver
.
If these are in two separate applications, make sure both are installed on your device or emulator, with the latest code (i.e., you didn't make the change and then fail to install the updated app).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With