隐式Intent启动Activity不成功问题

来源:互联网 发布:淘宝代怎么刷大金额 编辑:程序博客网 时间:2024/06/07 00:03

今天使用隐式Intention启动Activity不成功。看了官方的文档介绍才发现 少了

<category android:name="android.intent.category.DEFAULT" />

正确的方式:

<activity    android:name=".WebDemo"    android:label="@string/title_activity_web_demo"    android:theme="@style/AppTheme.NoActionBar" >    <intent-filter>        <action android:name="android.intent.action_WEBDEMO" />        <category android:name="android.intent.category.DEFAULT" />    </intent-filter></activity>

Note: In order to receive implicit intents, you must include theCATEGORY_DEFAULT category in the intent filter. The methodsstartActivity() andstartActivityForResult() treat all intentsas if they declared the CATEGORY_DEFAULT category.If you do not declare it in your intent filter, no implicit intents will resolve toyour activity.

0 0
原创粉丝点击