音楽アプリケーションを再生しようとしましたが、次のエラーが表示されました:
07-22 15:44:14.936: W/KeyCharacterMap(277): No keyboard for id 0
07-22 15:44:14.936: W/KeyCharacterMap(277): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
07-22 15:44:17.546: D/AndroidRuntime(277): Shutting down VM
07-22 15:44:17.546: W/dalvikvm(277): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
07-22 15:44:17.596: E/AndroidRuntime(277): FATAL EXCEPTION: main
07-22 15:44:17.596: E/AndroidRuntime(277): java.lang.RuntimeException: Unable to pause activity {com.testasaf.asaf.guttman/com.testasaf.asaf.guttman.Intro}: java.lang.NullPointerException
07-22 15:44:17.596: E/AndroidRuntime(277): at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3348)
07-22 15:44:17.596: E/AndroidRuntime(277): at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3305)
07-22 15:44:17.596: E/AndroidRuntime(277): at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:3288)
07-22 15:44:17.596: E/AndroidRuntime(277): at android.app.ActivityThread.access$2500(ActivityThread.java:125)
07-22 15:44:17.596: E/AndroidRuntime(277): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2040)
07-22 15:44:17.596: E/AndroidRuntime(277): at android.os.Handler.dispatchMessage(Handler.java:99)
07-22 15:44:17.596: E/AndroidRuntime(277): at android.os.Looper.loop(Looper.java:123)
07-22 15:44:17.596: E/AndroidRuntime(277): at android.app.ActivityThread.main(ActivityThread.java:4627)
07-22 15:44:17.596: E/AndroidRuntime(277): at java.lang.reflect.Method.invokeNative(Native Method)
07-22 15:44:17.596: E/AndroidRuntime(277): at java.lang.reflect.Method.invoke(Method.java:521)
07-22 15:44:17.596: E/AndroidRuntime(277): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
07-22 15:44:17.596: E/AndroidRuntime(277): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
07-22 15:44:17.596: E/AndroidRuntime(277): at dalvik.system.NativeStart.main(Native Method)
07-22 15:44:17.596: E/AndroidRuntime(277): Caused by: java.lang.NullPointerException
07-22 15:44:17.596: E/AndroidRuntime(277): at com.testasaf.asaf.guttman.Intro.onPause(Intro.java:41)
07-22 15:44:17.596: E/AndroidRuntime(277): at android.app.Activity.performPause(Activity.java:3842)
07-22 15:44:17.596: E/AndroidRuntime(277): at android.app.Instrumentation.callActivityOnPause(Instrumentation.java:1190)
07-22 15:44:17.596: E/AndroidRuntime(277): at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3335)
07-22 15:44:17.596: E/AndroidRuntime(277): ... 12 more
07-22 15:44:19.685: I/Process(277): Sending signal. PID: 277 SIG: 9
これがコードです
package com.testasaf.asaf.guttman;
import com.testasaf.asaf.guttman.R;
import android.app.Activity;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Bundle;
public class Intro extends Activity {
MediaPlayer someSong;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.intro);
MediaPlayer someSong= MediaPlayer.create(Intro.this,R.raw.music);//create an media player object
someSong.start();//start the music
Thread timer= new Thread(){//create new thread with anonymous class
public void run(){
try{
sleep(5000);//5 second pause
}catch(Exception e){
e.printStackTrace();//print the stack trace if hvae an error
}finally{
Intent saIntent=new Intent("com.testasaf.asaf.guttman.STARTINGPOINT");
startActivity(saIntent);//Calling the other activity
}
}
};
timer.start();
}
protected void onPause() {
super.onPause();
someSong.release();//release the song
finish();
}
}
エラーはリリース方法にあると思います。イントラネットとStackOverflowで検索しましたが、答えが見つかりませんでした。