3

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?

CoffeeSaurus
  • 105
  • 1
  • 11
  • Have you tried adding "" to intent-filter? – atastrumf Feb 06 '15 at 19:08
  • Since this is an explicit intent, I don't need to specify a default because I'm calling that activity directly. However, I did resolve the issue. I didn't realize that I needed to specify the full path of the class name as the second parameter of my ComponentName object. Thanks anyway! – CoffeeSaurus Feb 06 '15 at 19:24

1 Answers1

5

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");
Dale K
  • 25,246
  • 15
  • 42
  • 71
CoffeeSaurus
  • 105
  • 1
  • 11