简体   繁体   English

Android:ActivityNotFoundException

[英]Android: ActivityNotFoundException

I'm new to android and java programming and I'm getting ActivityNotFoundException in my app. 我是android和java编程的新手,我的应用程序中出现ActivityNotFoundException。

Here these are the only two times the activity is called: 这是活动被调用的仅有两次:

public void onItemClick(AdapterView<?> parent, View view,
                int position, long id) {
            // TODO Auto-generated method stub
            String selectedItem = (String) lvCheckLists.getItemAtPosition(position);

            Intent i= new Intent("com.teamvdb.checklist.checkListActivity");
            // Package name and activity
            // Intent i= new Intent(MainActivity.this,SecondActivity.Class);
            // Explicit intents
            i.putExtra("selectedItem",selectedItem);
            // Parameter 1 is the key
            // Parameter 2 is your value
             startActivity(i);

             Intent openCheckListActivity = new ntent("com.teamvdb.checklist.checkListActivity");
             startActivity(openCheckListActivity);

        }
    }); 
}

And here there is my Android Manifest: 这是我的Android清单:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.teamvdb.checklist"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="11"
    android:targetSdkVersion="21" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >

    <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=".checkListActivity"
    android:label="@string/app_name">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.MAIN" />

    </intent-filter>
</activity>
</application>
</manifest>

I have spent the last 20 minutes trying to figure out what is wrong with it but I can't see the problem. 我花了最后20分钟的时间来弄清楚问题出在哪里,但我看不到问题所在。 And yes the class is spelled correctly. 是的,该课程拼写正确。

Explicitly start checkListActivity : 显式启动checkListActivity:

public void onItemClick(AdapterView<?> parent, View view,int position, long id) {
    String selectedItem = (String) lvCheckLists.getItemAtPosition(position);
    Intent i= new Intent(MainActivity.this,checkListActivity.class);
    i.putExtra("selectedItem",selectedItem);
    startActivity(i);
});

intent-filter not required for checkListActivity so remove it and define as simple in AndroidManifest.xml : checkListActivity不需要intent过滤器,因此请删除它并在AndroidManifest.xml中将其定义为simple:

<activity android:name=".checkListActivity"/>

Note : Remove unneccsary code which start checkListActivity again. 注意:删除不必要的代码,这些代码再次启动checkListActivity。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM