Android ActivityNotFoundException

Android ActivityNotFoundException,android,android-intent,Android,Android Intent,我试图创建一个非常简单的自定义意图示例。我已经搜索了这个错误,没有一个论坛有适合我的答案。这是我的档案: public class DemoImplicit extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedIn

我试图创建一个非常简单的自定义意图示例。我已经搜索了这个错误,没有一个论坛有适合我的答案。这是我的档案:

public class DemoImplicit extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }

    public void whenButtonIsClicked(View view) {
        Intent intent = new Intent("com.example.action.NEW_ACTION"); //<<<<<<<
        intent.addCategory("android.intent.category.DEFAULT");       //<<<<<<<
//      Intent intent = new Intent("android.intent.action.VIEW");
//      intent.addCategory("com.example.MY_CATEGORY");
        startActivity(intent);                                       //<<<<<<<
    }
}

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.demos" android:versionCode="1"
    android:versionName="1.0">
    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".SatisfyIntent" android:label="@string/app_name">

          <intent-filter>
            <!-- action android:name="android.intent.action.VIEW" / -->
            <!-- category android:name="com.example.MY_CATEGORY" / -->
            <action android:name="com.example.action.NEW_ACTION" />
            <category android:name="android.intent.category.DEFAULT" />
          </intent-filter>
        </activity>

    </application>
    <uses-sdk android:minSdkVersion="9" />

</manifest> 
这两个单独的文件位于两个不同的Eclipse项目中,但我确保在将包含startActivity调用的文件加载到emulator之前,将包含intent筛选器的项目加载到emulator中。在任何情况下,我都会得到ActivityNotFoundException。 我做错了什么

另外,以下是包含DemoImplicit.java的项目的AndroidManifest.xml文件:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.example.demos"
      android:versionCode="1"
      android:versionName="1.0">
    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".DemoImplicit"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>
    <uses-sdk android:minSdkVersion="9" />

</manifest> 

首先,您应该确保您的AndroidManifest.xml文件必须已在此文件中定义了DemoImplicit活动

就这样:

此外,在代码中,您还将SatisfyIntent指定为启动程序活动

但在这里,您的Java代码中似乎没有类似的内容


因此,底线是:您要运行的活动必须在您的AndroidManifest.xml文件中定义。

首先,您应该确保您的AndroidManifest.xml文件必须在此文件中定义了DemoImplicit活动

就这样:

此外,在代码中,您还将SatisfyIntent指定为启动程序活动

但在这里,您的Java代码中似乎没有类似的内容


所以底线是:您想要运行的活动必须在您的AndroidManifest.xml文件中定义。

我已经有两个项目,所以我有两个AndroidManifest.xml文件。我对问题进行了编辑,将两者都包括在内。一个列出了一个启动器活动;另一个没有。所以我认为这不是问题所在。可能是标识符及其值之间的差异,比如com.example.demos.MY_ACTIVITY与值MY_NEW_ACTIVITY?我已经有两个项目,所以我有两个AndroidManifest.xml文件。我对问题进行了编辑,将两者都包括在内。一个列出了一个启动器活动;另一个没有。所以我认为这不是问题所在。它可能是标识符及其值之间的差异,比如com.example.demos.MY_ACTIVITY与值MY_NEW_ACTIVITY?