Reputation: 105
I have written two different applications, we'll call them AppA and AppB. I am trying to start an activity in AppA from AppB using an intent. I am trying to accomplish this with an explicit intent.
In AppB, I create the intent like this:
ComponentName cn = new ComponentName("com.example.user.appa",
"appaActivity");
Intent infoIntent = new Intent();
infoIntent.setComponent(cn);
infoIntent.setAction("com.example.DO_SOMETHING");
infoIntent.putStringArrayListExtra("arrList", incInfo);
startActivity(infoIntent);
In the AndroidManifest.xml for AppA, I have included the following:
<activity
android:name=".appaActivity"
android:label="@string/title_activity">
<intent-filter>
<action android:name="com.example.DO_SOMETHING"/>
</intent-filter>
</activity>
When I try to run AppB (which is sending the Intent to AppA, I get the following error:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.user.appb/com.example.user.appb.MainActivity}: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.user.appa/appaActivity}; have you declared this activity in your AndroidManifest.xml?
Since I can clearly see that I've defined appaActivity in AppA AndroidManifest.xml, can anyone tell me what I might be overlooking?
Upvotes: 3
Views: 1672
Reputation: 105
In AppB's ComponentName object, I wasn't providing the full path to the class name as I didn't realize it was necessary. Once I added that, it worked like a charm.
Corrected Component Name:
ComponentName cn = new ComponentName("com.example.user.appa",
"com.example.user.appa.appaActivity");
Upvotes: 5