2
votes

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>
1

1 Answers

1
votes

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")