隱式Intent啓動Activity不成功問題

今天使用隱式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.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章