Android应用程序崩溃

时间:2012-11-19 12:52:34

标签: android android-intent crash android-manifest

我的应用程序确实打开了启动画面并播放了背景音乐..但之后它应该打开列表活动但它崩溃了 我曾尝试使用其他几乎一切的名称运行相同的程序,但当我重新输入程序时它崩溃了..我已经清理和刷新,甚至没有任何区别

我的java文件

Splash.java:

package com.alpha.beta;

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 beta) {
    super.onCreate(beta);
    setContentView(R.layout.splash);
    ourSong = MediaPlayer.create(Splash.this, R.raw.splash_sound);
    ourSong.start();
    Thread timer = new Thread(){
        public void run(){
            try {
                sleep(5100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            } finally {
                Intent openStartingPoint = new Intent("com.alpha.beta.MENU");
                startActivity(openStartingPoint);
            }
        }
    };
    timer.start();
}

    @Override
    protected void onPause() {
        super.onPause();
        ourSong.release();
        finish();
}
}

清单文件:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.alpha.beta"
android:versionCode="1"
android:versionName="1.0" >

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

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".Splash"
        android:label="@string/title_activity_app" >
        <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/title_activity_app" >
        <action android:name="com.alpha.beta.MENU" />

        <category android:name="android.intent.category.DEFAULT" />
    </activity>
    <activity
        android:name=".App"
        android:label="@string/title_activity_app" >
        <action android:name="com.alpha.beta.APP" />

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

           11-19 18:35:42.291: W/dalvikvm(882): threadid=7: thread exiting with uncaught exception (group=0x4001d800)
           11-19 18:35:42.321: E/AndroidRuntime(882): FATAL EXCEPTION: Thread-8
           11-19 18:35:42.321: E/AndroidRuntime(882): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.alpha.beta.Menu }
           11-19 18:35:42.321: E/AndroidRuntime(882):   at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1408)
           11-19 18:35:42.321: E/AndroidRuntime(882):   at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
           11-19 18:35:42.321: E/AndroidRuntime(882):   at android.app.Activity.startActivityForResult(Activity.java:2817)
           11-19 18:35:42.321: E/AndroidRuntime(882):   at android.app.Activity.startActivity(Activity.java:2923)
           11-19 18:35:42.321: E/AndroidRuntime(882):   at com.alpha.beta.Splash$1.run(Splash.java:26)
           11-19 18:35:46.190: I/Process(882): Sending signal. PID: 882 SIG: 9

2 个答案:

答案 0 :(得分:1)

试试这种方式

  Intent openStartingPoint = new Intent(Splash.this,Menu.class);
  startActivity(openStartingPoint);

修改: - 有时候问题是没有获取该活动的上下文。这就是为什么你可能会因为ActivityNotFoundException而获得异常。

答案 1 :(得分:0)

只是一个想法。在意图中,您已将类名指定为 MENU ,但在清单中,它是菜单。尝试更改它,区分大小写可能是一个问题。同时为菜单类定义操作。操作名称应为 VIEW

如果是,则活动(启动和菜单)是否属于同一个包 然后尝试

    Intent i = new Intent(Splash.this, Menu.class);
    i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

startActivity(i);