我正在开发一个使用 AndEngine 的 Android 应用程序。我尝试以这种方式重新启动活动:
private void restartActivity() {
startActivity(new Intent(this, TMXTiledMapExample.class));
finish();
}
该解决方案适用于大多数设备,但我意识到这不适用于 Nexus4。
事实上,我收到以下错误:
08-06 11:24:17.416: E/AndroidRuntime(6299): FATAL EXCEPTION: main
08-06 11:24:17.416: E/AndroidRuntime(6299): java.lang.NullPointerException
08-06 11:24:17.416: E/AndroidRuntime(6299): at org.andengine.ui.activity.BaseGameActivity.onResumeGame(BaseGameActivity.java:222)
08-06 11:24:17.416: E/AndroidRuntime(6299): at org.andengine.ui.activity.BaseGameActivity$4.run(BaseGameActivity.java:373)
08-06 11:24:17.416: E/AndroidRuntime(6299): at android.os.Handler.handleCallback(Handler.java:730)
08-06 11:24:17.416: E/AndroidRuntime(6299): at android.os.Handler.dispatchMessage(Handler.java:92)
08-06 11:24:17.416: E/AndroidRuntime(6299): at android.os.Looper.loop(Looper.java:137)
08-06 11:24:17.416: E/AndroidRuntime(6299): at android.app.ActivityThread.main(ActivityThread.java:5103)
08-06 11:24:17.416: E/AndroidRuntime(6299): at java.lang.reflect.Method.invokeNative(Native Method)
08-06 11:24:17.416: E/AndroidRuntime(6299): at java.lang.reflect.Method.invoke(Method.java:525)
08-06 11:24:17.416: E/AndroidRuntime(6299): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
08-06 11:24:17.416: E/AndroidRuntime(6299): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
08-06 11:24:17.416: E/AndroidRuntime(6299): at dalvik.system.NativeStart.main(Native Method)