开发者

Unable to launch an activity using implicit intent specifying only action

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 开发者_C百科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>


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜