0

我最近开始学习如何使用 eclipse 开发应用程序,我已经为它制作了一个应用程序和一个菜单。打开应用程序后,我得到了启动屏幕,它应该停留 5 秒钟,然后进入菜单。启动屏幕后,应用程序崩溃。我正在开发 4.1.2。我的日志猫报告如下

05-08 13:46:21.170: V/MediaPlayer(16864): message received msg=2, ext1=0, ext2=0

05-08 13:46:21.170: V/MediaPlayer(16864): playback complete

05-08 13:46:21.170: V/MediaPlayer(16864): callback application

05-08 13:46:21.170: V/MediaPlayer(16864): back from callback

05-08 13:46:23.585: D/Instrumentation(16864): 
checkStartActivityResult  :Intent { act=com.example.first_app.MENU }

05-08 13:46:23.585: D/Instrumentation(16864): 
checkStartActivityResult  inent is instance of inent:

05-08 13:46:23.590: W/dalvikvm(16864): threadid=11: thread exiting with uncaught exception (group=0x40f122a0)
05-08 13:46:23.590: E/AndroidRuntime(16864): FATAL EXCEPTION: Thread-1262

05-08 13:46:23.590: E/AndroidRuntime(16864): android.content.ActivityNotFoundException: No 
Activity found to handle Intent { act=com.example.first_app.MENU }

05-08 13:46:23.590: E/AndroidRuntime(16864):    at 

android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1580)
05-08 13:46:23.590: E/AndroidRuntime(16864):    at 

android.app.Instrumentation.execStartActivity(Instrumentation.java:1431)
05-08 13:46:23.590: E/AndroidRuntime(16864):    at 

android.app.Activity.startActivityForResult(Activity.java:3446)
05-08 13:46:23.590: E/AndroidRuntime(16864):    at 

android.app.Activity.startActivityForResult(Activity.java:3407)
05-08 13:46:23.590: E/AndroidRuntime(16864):    at 

android.app.Activity.startActivity(Activity.java:3617)
05-08 13:46:23.590: E/AndroidRuntime(16864):    at 

android.app.Activity.startActivity(Activity.java:3585)
05-08 13:46:23.590: E/AndroidRuntime(16864):    at 

com.example.first_app.Splash$1.run(Splash.java:28)

05-08 13:46:23.615: V/MediaPlayer-JNI(16864): release

05-08 13:46:23.615: V/MediaPlayer(16864): setListener

05-08 13:46:23.615: V/MediaPlayer(16864): disconnect

05-08 13:46:23.620: V/MediaPlayer(16864): destructor

05-08 13:46:23.620: V/MediaPlayer(16864): disconnect

我的代码是

package com.example.first_app;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class Menu extends ListActivity{

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



@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
    super.onListItemClick(l, v, position, id);
    String cheese = classes[position];
    try{                    
    Class ourClass = Class.forName("com.example.first_app." + cheese);
    Intent ourIntent = new Intent(Menu.this, ourClass);
    startActivity(ourIntent);
    }catch(ClassNotFoundException e){
        e.printStackTrace();
    }
}   
}

我也有我的清单

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

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

<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=".startingPoint"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="com.example.first_app" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
    <activity
        android:name=".Menu"  android:label="@string/app_name" >
        <intent-filter>
            <action android:name="come.example.first_app.MENU" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
</application>
</manifest>
4

1 回答 1

1

你有一个错字: <action android:name="**come**.example.first_app.MENU" />

你的意思是输入“com”而不是“come”

仅供参考:我发现的方式是在错误日志中。该行:

05-08 13:46:23.590: E/AndroidRuntime(16864): android.content.ActivityNotFoundException: No 

发现处理 Intent { act=com.example.first_app.MENU } 的活动

告诉我,在您的应用程序中,您试图创建一个名为“com.example.first_app.MENU”的活动,但该活动不是您项目的一部分。我希望您的 android 清单根本没有该节点。但我发现它在那里有一个错字。希望对您有所帮助。

于 2013-05-09T16:36:10.557 回答