我今天上传了一个 Android 应用程序,有人报告了带有 RunTimeException 和 NullPointerException 的崩溃报告。当用户尝试通过使用AlertDialog
. 报告如下。
java.lang.RuntimeException: Unable to start activity
ComponentInfo{pacakageName/packageName.PlayScreen}:
java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2001)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2028)
at android.app.ActivityThread.access$600(ActivityThread.java:127)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1179)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4508)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:809)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:576)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at pacakageName.PlayScreen.onCreate(PlayScreen.java:104)
at android.app.Activity.performCreate(Activity.java:4479)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1050)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1965)
... 11 more
这是来自 PlayScreen.java 的一些代码,
MediaPlayer big_loop
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.play_screen);
big_loop = MediaPlayer.create(PlayScreen.this, R.raw.big_loop);
//Line 104
big_loop.start();
big_loop.setLooping(true);}
在游戏结束时,在一个AlertDialog
,当使用正面按钮时,
dialog.dismiss();
Intent i = new Intent(PlayScreen.this,PlayScreen.class);
startActivity(i);
finish();