簡體   English   中英

Android:ActivityNotFoundException

[英]Android: ActivityNotFoundException

我是android和java編程的新手,我的應用程序中出現ActivityNotFoundException。

這是活動被調用的僅有兩次:

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);

        }
    }); 
}

這是我的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>

我花了最后20分鍾的時間來弄清楚問題出在哪里,但我看不到問題所在。 是的,該課程拼寫正確。

顯式啟動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);
});

checkListActivity不需要intent過濾器,因此請刪除它並在AndroidManifest.xml中將其定義為simple:

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

注意:刪除不必要的代碼,這些代碼再次啟動checkListActivity。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM