无法在Android中使用自定义意图操作打开第二个应用

无法在Android中使用自定义意图操作打开第二个应用,android,intentfilter,Android,Intentfilter,我已经编写了一个处理一些特定意图过滤器的应用程序,下面是该应用程序的清单: <?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" &

我已经编写了一个处理一些特定意图过滤器的应用程序,下面是该应用程序的清单:

<?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();
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 }

请帮忙。

我想你在
中遗漏了

试一试

<intent-filter>
  <action android:name="com.company.sampleapp.ACTION_DO_SOMETHING_1" />
  <data android:mimeType="*/*"/>
  <category android:name="android.intent.category.DEFAULT" />
</intent-filter>


您创建的意图只能从当前应用运行活动。
您可以使用另一个应用程序

Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage("com.package.address");
startActivity(LaunchIntent);
查看此表格了解更多信息

Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage("com.package.address");
startActivity(LaunchIntent);