我正在尝试使用在AndEngine中启动另一个活动意图,因为我在原始Android应用中使用它,它不起作用。
logcat的:
02-19 18:32:49.682: E/AndroidRuntime(1794): FATAL EXCEPTION: main
02-19 18:32:49.682: E/AndroidRuntime(1794): java.lang.NullPointerException
02-19 18:32:49.682: E/AndroidRuntime(1794): at org.andengine.ui.activity.BaseGameActivity.onResumeGame(BaseGameActivity.java:222)
02-19 18:32:49.682: E/AndroidRuntime(1794): at org.andengine.ui.activity.BaseGameActivity$4.run(BaseGameActivity.java:373)
02-19 18:32:49.682: E/AndroidRuntime(1794): at android.os.Handler.handleCallback(Handler.java:730)
02-19 18:32:49.682: E/AndroidRuntime(1794): at android.os.Handler.dispatchMessage(Handler.java:92)
02-19 18:32:49.682: E/AndroidRuntime(1794): at android.os.Looper.loop(Looper.java:137)
02-19 18:32:49.682: E/AndroidRuntime(1794): at android.app.ActivityThread.main(ActivityThread.java:5289)
02-19 18:32:49.682: E/AndroidRuntime(1794): at java.lang.reflect.Method.invokeNative(Native Method)
02-19 18:32:49.682: E/AndroidRuntime(1794): at java.lang.reflect.Method.invoke(Method.java:525)
02-19 18:32:49.682: E/AndroidRuntime(1794): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
02-19 18:32:49.682: E/AndroidRuntime(1794): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555)
02-19 18:32:49.682: E/AndroidRuntime(1794): at dalvik.system.NativeStart.main(Native Method)
代码:
startActivity(new Intent(StartingActivity.this, MainActivity.class));
finish();
请注意,有时它会起作用,有时却不起作用。
答案 0 :(得分:1)
答案 1 :(得分:0)
@Override
public synchronized void onResumeGame() {
if (this.mEngine != null)
super.onResumeGame();
}
使用此代码解析它,引用https://github.com/nicolasgramlich/AndEngine/issues/7