gpt4 book ai didi

安卓:ActivityNotFoundException

转载 作者:行者123 更新时间:2023-11-30 02:29:51 24 4
gpt4 key购买 nike

我是 android 和 java 编程的新手,我在我的应用程序中收到 ActivityNotFoundException。

这里是 Activity 被调用的仅有的两次:

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 list :

<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 分钟试图弄清楚它出了什么问题,但我看不到问题所在。是的,类(class)拼写正确。

最佳答案

显式启动 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-filter,所以删除它并在 AndroidManifest.xml 中定义为简单:

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

注意:删除不必要的再次启动checkListActivity的代码。

关于安卓:ActivityNotFoundException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27457473/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com