AndEngine GLES 2.0 – Power button issue – App Crashes onResume()-Collection of common programming errors
App crashes when i press power button to lock screen and press it again to unlock screen. App crashes after scren gets unlocked.
This is a stackTress i got in logcat:
05-09 18:46:57.254: E/AndroidRuntime(25354): FATAL EXCEPTION: main
05-09 18:46:57.254: E/AndroidRuntime(25354): java.lang.NullPointerException
05-09 18:46:57.254: E/AndroidRuntime(25354): at org.andengine.ui.activity.BaseGameActivity.onResumeGame(BaseGameActivity.java:222)
05-09 18:46:57.254: E/AndroidRuntime(25354): at org.andengine.ui.activity.BaseGameActivity$4.run(BaseGameActivity.java:373)
05-09 18:46:57.254: E/AndroidRuntime(25354): at android.os.Handler.handleCallback(Handler.java:615)
05-09 18:46:57.254: E/AndroidRuntime(25354): at android.os.Handler.dispatchMessage(Handler.java:92)
05-09 18:46:57.254: E/AndroidRuntime(25354): at android.os.Looper.loop(Looper.java:137)
05-09 18:46:57.254: E/AndroidRuntime(25354): at android.app.ActivityThread.main(ActivityThread.java:4744)
05-09 18:46:57.254: E/AndroidRuntime(25354): at java.lang.reflect.Method.invokeNative(Native Method)
05-09 18:46:57.254: E/AndroidRuntime(25354): at java.lang.reflect.Method.invoke(Method.java:511)
05-09 18:46:57.254: E/AndroidRuntime(25354): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
05-09 18:46:57.254: E/AndroidRuntime(25354): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
05-09 18:46:57.254: E/AndroidRuntime(25354): at dalvik.system.NativeStart.main(Native Method)
Nullpointer Exception at onResumeGame() method of BaseGameActivityClass.
I have added this line in “activity” tag of manifest
android:configChanges="orientation|keyboard|keyboardHidden"
in my GameActivity which extends BaseGameActivity i have added this
@Override
public void onPause() {
super.onPause();
mEngine.stop();
}
@Override
protected void onResume() {
// The activity has become visible (it is now "resumed").
super.onResume();
mEngine.start();
}
What is wrong? What shall i do to stop crashing game on power button issue?