java - Android:找不到处理 Intent 的 Activity

标签 java android eclipse android-activity

运行程序时出现此错误。它启动第一页,但是当它应该转到 .Menu 时它崩溃了:

11-04 06:01:06.039: W/dalvikvm(949): threadid=11: thread exiting with uncaught exception (group=0x414c4700)
11-04 06:01:06.057: E/AndroidRuntime(949): FATAL EXCEPTION: Thread-87
11-04 06:01:06.057: E/AndroidRuntime(949): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.example.secondapp.MENU }
11-04 06:01:06.057: E/AndroidRuntime(949):  at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1632)
11-04 06:01:06.057: E/AndroidRuntime(949):  at android.app.Instrumentation.execStartActivity(Instrumentation.java:1424)
11-04 06:01:06.057: E/AndroidRuntime(949):  at android.app.Activity.startActivityForResult(Activity.java:3390)
11-04 06:01:06.057: E/AndroidRuntime(949):  at android.app.Activity.startActivityForResult(Activity.java:3351)
11-04 06:01:06.057: E/AndroidRuntime(949):  at android.app.Activity.startActivity(Activity.java:3587)
11-04 06:01:06.057: E/AndroidRuntime(949):  at android.app.Activity.startActivity(Activity.java:3555)
11-04 06:01:06.057: E/AndroidRuntime(949):  at com.example.secondapp.Splash$1.run(Splash.java:26)

这是我的 list :

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

    <uses-sdk
        android:minSdkVersion="11"
        android:targetSdkVersion="18" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >

        <activity
            android:name=".Splash"
            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=".Menu"
            android:label="@string/app_name" >
         <intent-filter>
                <action android:name="android.intent.action.MENU" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
         <intent-filter>
                <action android:name="android.intent.action.MAINACTIVITY" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

    </application>

</manifest>

这是我的 .Splash Activity 和 .Menu Activity 的 .java 文件:

飞溅

    package com.example.secondapp;

     import android.app.Activity;
     import android.content.Intent;
     import android.media.MediaPlayer;
     import android.os.Bundle;

    public class Splash extends Activity {

    MediaPlayer ourSong;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.splash);
        ourSong = MediaPlayer.create(Splash.this, R.raw.happyman);
        ourSong.start();
        Thread timer = new Thread(){
            public void run(){
                try{
                    sleep(5000);
                } catch (InterruptedException e){
                    e.printStackTrace();
                }finally{
                    Intent startMain = new Intent("com.example.secondapp.MENU");
                    startActivity(startMain);
                }
            }
        };
        timer.start();
    }

    @Override
    protected void onPause() {
        // TODO Auto-generated method stub
        super.onPause();
        finish();
    }


}

菜单

package com.example.secondapp;


public class Menu extends ListActivity {

String classes[] = {"MainActivity", "example1", "example2", "example3", "example4", "example5"};

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setListAdapter(new ArrayAdapter<String>(Menu.this, android.R.layout.simple_list_item_1, classes));
}

@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
    // TODO Auto-generated method stub
    String Cheese = classes[position];
    super.onListItemClick(l, v, position, id);
    try{
    Class ourClass = Class.forName("com.example.secondapp." + Cheese);
    Intent ourIntent = new Intent(Menu.this, ourClass);
    startActivity(ourIntent);
    }catch(ClassNotFoundException e){
        e.printStackTrace();
    }
}

 }

最佳答案

在你的 list 中,操作应该匹配。使用 com.example.secondapp.MENU

更改它

关于java - Android:找不到处理 Intent 的 Activity ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19766481/

相关文章:

android - 为什么某些 Android API 没有显示在 AVD Manager 目标选项卡中?

java - 在 Eclipse RCP 4 应用程序中查找现有作业

java - 控制台上的 servlet 错误不会重定向到错误页面

android - 为什么应用程序突然与某些设备不兼容?

java - 在显示 Activity 之前预加载 Activity ?

android - 如何只创建一次数据库,然后从中多次读取和写入,SQLite,OpenHelper,Android

安卓工作室 : Gradle does not build sql database

Eclipse 3.7(indigo SR2)m2e(1.1)导入Maven不会添加生成源的源文件夹

java - 如何在Activity之间传递ObservableInt?

java - 多线程工作负载中的原子操作