9

I am trying to start an activity defined in another apk, in its AndroidManifest.xml, it defines an activity and with an action, but no category defined.

The format is like

<activity name="...">
    <intent-filter>
        <action android:name="action name">
    <intent-filter>
</activity>

My code is following

Intent i = new Intent("action name");
startActivity(i);

However my apk crashed with uncaught ActivityNotFound exception, the logs read No Activity found to handle intent ... "

Any thoughts?

Thanx a lot.

Jimmy
  • 573
  • 4
  • 9
  • 14

3 Answers3

19

Looking at the Intent documentation, it says Note also the DEFAULT category supplied here: this is required for the Context.startActivity method to resolve your activity when its component name is not explicitly specified. If the activity's IntentFilter definition does not include that category then you can't start it with startActivity. Try using the setClassName method, and pass it the package class and the activity class you're trying to launch.

Femi
  • 64,273
  • 8
  • 118
  • 148
16

you cannot have empty category when you use startActivity(...).

add a default category and this will do the job:

<intent-filter>
    <action android:name="action name" />
    <category android:name="android.intent.category.DEFAULT" />
</intent-filter>
Ragunath Jawahar
  • 19,513
  • 22
  • 110
  • 155
Mark
  • 5,466
  • 3
  • 23
  • 24
0

You need to define the activity you are starting in your Manifest. Make sure you have provided same <intent-action (and name of the activity) that has the activity in the other apk you want to start.

android: how do i open another app from my app?

Community
  • 1
  • 1
Nikola Despotoski
  • 49,966
  • 15
  • 119
  • 148
  • Can you give more details about the intent definition in manifest? How do I include activity in the other apk in my manifest? – Jimmy Dec 21 '11 at 00:35