首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >安卓: ActivityNotFoundException

安卓: ActivityNotFoundException
EN

Stack Overflow用户
提问于 2014-12-13 09:40:50
回答 1查看 116关注 0票数 1

我对android和java编程很陌生,我的应用程序中也有ActivityNotFoundException。

在这里,只有两次这个活动被称为:

代码语言:javascript
复制
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宣言:

代码语言:javascript
复制
<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分钟试图找出它的问题所在,但我看不出问题所在。是的,这门课拼写正确。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-12-13 09:46:57

显式启动checkListActivity:

代码语言:javascript
复制
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不需要筛选器,所以删除它,并在AndroidManifest.xml中定义为简单:

代码语言:javascript
复制
<activity android:name=".checkListActivity"/>

注释:删除再次启动checkListActivity的不相关代码。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27457473

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档