代码:
package com.guess.guessthefone;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
public class MainActivity extends Activity {
MediaPlayer logoMusic;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
MediaPlayer logoMusic = MediaPlayer.create(MainActivity.this, R.raw.splash_sound);
logoMusic.start();
Thread logoTimer = new Thread(){
public void run(){
try{
sleep(2000);
Intent MenuIntent = new Intent("com.guess.guessthefone.SPLASH");
startActivity(MenuIntent);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finally{
finish();
}
}
};
logoTimer.start();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
我的 LogCat 输出是:
08-24 16:40:33.558: D/dalvikvm(322): GC_EXTERNAL_ALLOC freed 48K, 53% free 2551K/5379K, external 1625K/2137K, paused 74ms
08-24 16:40:36.048: W/dalvikvm(322): threadid=9: thread exiting with uncaught exception (group=0x40015560)
08-24 16:40:36.057: E/AndroidRuntime(322): FATAL EXCEPTION: Thread-10
08-24 16:40:36.057: E/AndroidRuntime(322): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.guess.guessthefone.Menu }
08-24 16:40:36.057: E/AndroidRuntime(322): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1409)
08-24 16:40:36.057: E/AndroidRuntime(322): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1379)
08-24 16:40:36.057: E/AndroidRuntime(322): at android.app.Activity.startActivityForResult(Activity.java:2827)
08-24 16:40:36.057: E/AndroidRuntime(322): at android.app.Activity.startActivity(Activity.java:2933)
08-24 16:40:36.057: E/AndroidRuntime(322): at com.guess.guessthefone.MainActivity$2.run(MainActivity.java:29)