tags:

views:

362

answers:

1

I am trying to launch an activity by specifying only its action(custom) defined in its intent filter from an activity in other application. The activity to be launched is the main activity of its application thus have android.intent.action.MAIN & android.intent.category.LAUNCHER set as action and category in its intent filter. Now according to android doc on Intent and Intent Filter, i do not need to specify DEFAULT category at all in this case. But doing the same i am i am unable to launch the activity.

LogCat says, Activity could not be found...

Am i misinterpreting the text or is there something else missing...?

Code, used for calling the activity

Intent i=new Intent();
i.setAction("android.AddressBookV4.firstActivity");
startActivity(i);

Definition of Activity being called in the manifest file

<activity android:name=".AddressBook"
          android:label="@string/app_name">
     <intent-filter>
         <action android:name="android.AddressBookV4.firstActivity" />
         <action android:name="android.intent.action.MAIN" />
         <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
</activity>
A: 

You need to add the LAUNCHER category to your Intent, since the <intent-filter> says that it matches the following Intents (in pseudocode):

((action IS "android.AddressBookV4.firstActivity")
    OR (action IS "android.intent.action.MAIN"))
  AND (category IS "android.intent.category.LAUNCHER")
CommonsWare
but intent with no category should had passed the category test. Also acc. to docs default category which is there in the intent object need not to be mention in case of activity which is set for 'main' action with category as 'Launcher'.
Amit
"but intent with no category should had passed the category test" -- no, it won't. You need to add the `LAUNCHER` category to your `Intent`.
CommonsWare