gpt4 book ai didi

Android 致命异常 ActivityNotFoundException

转载 作者:行者123 更新时间:2023-11-29 21:15:39 26 4
gpt4 key购买 nike

首先,我使用的是 Eclipse IDE。我正在尝试制作一个应用程序商店。我不知道发生了什么,但它以前有效,现在我在 LogCat 中收到此错误。

02-02 13:26:39.750: E/AndroidRuntime(280): FATAL EXCEPTION: main
02-02 13:26:39.750: E/AndroidRuntime(280): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.example.appstore.GAMENAME }
02-02 13:26:39.750: E/AndroidRuntime(280): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1408)
02-02 13:26:39.750: E/AndroidRuntime(280): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
02-02 13:26:39.750: E/AndroidRuntime(280): at android.app.Activity.startActivityForResult(Activity.java:2817)
02-02 13:26:39.750: E/AndroidRuntime(280): at android.app.Activity.startActivity(Activity.java:2923)
02-02 13:26:39.750: E/AndroidRuntime(280): at com.servetech.appstore.MainActivity$1.onClick(MainActivity.java:28)
02-02 13:26:39.750: E/AndroidRuntime(280): at android.view.View.performClick(View.java:2408)
02-02 13:26:39.750: E/AndroidRuntime(280): at android.view.View$PerformClick.run(View.java:8816)
02-02 13:26:39.750: E/AndroidRuntime(280): at android.os.Handler.handleCallback(Handler.java:587)
02-02 13:26:39.750: E/AndroidRuntime(280): at android.os.Handler.dispatchMessage(Handler.java:92)
02-02 13:26:39.750: E/AndroidRuntime(280): at android.os.Looper.loop(Looper.java:123)
02-02 13:26:39.750: E/AndroidRuntime(280): at android.app.ActivityThread.main(ActivityThread.java:4627)
02-02 13:26:39.750: E/AndroidRuntime(280): at java.lang.reflect.Method.invokeNative(Native Method)
02-02 13:26:39.750: E/AndroidRuntime(280): at java.lang.reflect.Method.invoke(Method.java:521)
02-02 13:26:39.750: E/AndroidRuntime(280): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
02-02 13:26:39.750: E/AndroidRuntime(280): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
02-02 13:26:39.750: E/AndroidRuntime(280): at dalvik.system.NativeStart.main(Native Method)

主 Activity .java

package com.servetech.appstore;


import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.View;
import android.widget.Button;

public class MainActivity extends Activity {


Button btn;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btn = (Button) findViewById(R.id.button1);

btn.setOnClickListener(
new View.OnClickListener() {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent myIntent = new Intent("com.example.appstore.GAMENAME");
startActivity(myIntent);
}
});

}



}

Android list :

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.servetech.appstore"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.servetech.appstore.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=".GameName"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.servetech.appstore.GAMENAME" />

<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>

</application>

PS:我注意到我启动 Activity 的方式与其他人略有不同。只是想让你知道我正在学习新波士顿教程。我希望这不是问题。如果需要,我可以发布 GameName 类。

编辑:已经解决了这个问题,所以不要浪费你的时间试图提供帮助:)

最佳答案

您尝试运行类 "com.example.appstore.GAMENAME 但在 list 中您得到了 packageName+.GameName。所以不是 Intent myIntent = new Intent("com.example.appstore.GAMENAME"); 试试 Intent myIntent = new Intent("com.servetech.appstore.GAMENAME");

关于Android 致命异常 ActivityNotFoundException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21510224/

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