Intent的隱式方式啟動Activity
<span style="background-color: rgb(255, 255, 255);"><span style="color:#3333ff;"><?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="xl.intent_filter.test" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="21" /> <uses-permission android:name="android.permission.INTERNET"/> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" android:name="XLApplication"> <activity android:name=".MainActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name="ImplicitAcitivity"> <intent-filter> </span><span style="color:#ff0000;"><category android:name="android.intent.category.DEFAULT" /></span><span style="color:#3333ff;"> <action android:name="android.intent.action.VIEW"/> <data android:mimeType="@string/image_all"/> </intent-filter> </activity> <receiver android:name="XlBroadcastReceiver"> <intent-filter> <action android:name="action.send.xl.broadcast"/> </intent-filter> </receiver> </application> </manifest></span></span><span style="color: rgb(255, 255, 255); background-color: rgb(51, 51, 255);"> </span>
Note: Android automatically applies the the category to all implicit intents passed to and . So if you want your activity to receive implicit intents, it must include a category for
"android.intent.category.DEFAULT"
in
its intent filters (as shown in the previous<intent-filter>
example.