简体   繁体   English

Android FATAL EXCEPTION ActivityNotFoundException

[英]Android FATAL EXCEPTION ActivityNotFoundException

Firstly, I am using Eclipse IDE. 首先,我正在使用Eclipse IDE。 I was trying to make an app store. 我试图建立一个应用商店。 I do not know what happened but it worked before, now I get this error in LogCat. 我不知道发生了什么,但是以前有用,现在我在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)

MainActivity.java MainActivity.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 manifest: Android清单:

<?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: I have noticed that I am starting Activity a bit differently than everyone else. PS:我注意到我开始活动与其他人有所不同。 Just to let you know I am learning from thenewboston tutorials. 只是为了让您知道我正在从newboston教程中学习。 I hope that is not the problem. 我希望这不是问题。 I can post the GameName class if required. 如果需要,我可以发布GameName类。

EDIT: Already solved this, so do not waste your time trying to help :) 编辑:已经解决了这个问题,所以不要浪费您的时间来帮助:)

您尝试运行类"com.example.appstore.GAMENAME但清单中显示的是packageName+.GameName 。因此,代替Intent myIntent = new Intent("com.example.appstore.GAMENAME");尝试Intent myIntent = new Intent("com.servetech.appstore.GAMENAME");

将活动意图更改为:

 Intent myIntent = new Intent("com.servetech.appstore.GAMENAME");

The real package of GAMENAME is com.servetech.appstore.GAMENAME not com.example.appstore.GAMENAME . GAMENAME的实际包是com.servetech.appstore.GAMENAME而不是com.example.appstore.GAMENAME That's why Android cannot found the activity. 这就是Android无法找到活动的原因。

android.content. android.content。 ActivityNotFound Exception: No Activity found to handle Intent ActivityNotFound异常: 找不到用于处理意图的活动

So 所以

Intent myIntent = new Intent("com.example.appstore.GAMENAME");

to

Intent myIntent = new Intent("com.servetech.appstore.GAMENAME");

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

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