我编写了一个处理一些特定意图过滤器的应用程序,这是应用程序的清单:
<?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 }
请帮忙。