我寫一個應用程序,它處理一些特定的意圖過濾器,這裏是應用程序的清單打開第二個應用程序:無法使用自定義意向行動的Android
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.company.sampleapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name">
<activity
android:name="com.company.sampleapp.MainActivity"
android:enabled="true"
android:exported="true"
android:label="@string/app_name" >
<!-- 1 filter -->
<intent-filter>
<action android:name="com.company.sampleapp.ACTION_DO_SOMETHING_1" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<!-- 2 filter -->
<intent-filter>
<action android:name="com.company.sampleapp.ACTION_DO_SOMETHING_2" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<!-- default filter -->
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.company.sampleapp.Seconf=dActivity"
/>
</application>
</manifest>
我打電話從第二個應用程序這個應用程序使用下面的代碼:
Intent i = new Intent("com.company.sampleapp.ACTION_DO_SOMETHING_1");
startActivityForResult(i, 100);
我也曾嘗試:
Intent i = new Intent();
i.setAction("com.company.sampleapp.ACTION_DO_SOMETHING_1");
startActivityForResult(i, 100);
但每當我收到以下例外:
07-18 14:22:56.234: E/AndroidRuntime(12051): Caused by: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.company.sampleapp.ACTION_DO_SOMETHING_1 }
請幫忙。