Skip to content

implicit intent 打开Activity 注意点 #24

Description

@chufengma

一般都是设置

<activity>
 <action android:name="com.example.demo.XXXX"  />  
</activity>

其它Application中的Activity 调用 startActivity:

Intent intent = new Intent("com.example.demo.XXXX");
startActivity(intent);

这个时候直接启动会失败,往往我们忘记在activity intent-filter中添加:

<activity>
 <action android:name="com.example.demo.XXXX"  />  
 <category android:name="android.intent.category.LAUNCHER" />
</activity>

In order to receive implicit intents, you must include the CATEGORY_DEFAULT category in the intent filter. The methods startActivity() and startActivityForResult() treat all intents as if they declared the CATEGORY_DEFAULT category. If you do not declare it in your intent filter, no implicit intents will resolve to your activity.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions