android - AndEngine GLES 2.0 - Power button issue - App Crashes onResume() -


app crashes when press power button lock screen , press again unlock screen. app crashes after scren gets unlocked.

this stacktress 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):    @ org.andengine.ui.activity.basegameactivity.onresumegame(basegameactivity.java:222) 05-09 18:46:57.254: e/androidruntime(25354):    @ org.andengine.ui.activity.basegameactivity$4.run(basegameactivity.java:373) 05-09 18:46:57.254: e/androidruntime(25354):    @ android.os.handler.handlecallback(handler.java:615) 05-09 18:46:57.254: e/androidruntime(25354):    @ android.os.handler.dispatchmessage(handler.java:92) 05-09 18:46:57.254: e/androidruntime(25354):    @ android.os.looper.loop(looper.java:137) 05-09 18:46:57.254: e/androidruntime(25354):    @ android.app.activitythread.main(activitythread.java:4744) 05-09 18:46:57.254: e/androidruntime(25354):    @ java.lang.reflect.method.invokenative(native method) 05-09 18:46:57.254: e/androidruntime(25354):    @ java.lang.reflect.method.invoke(method.java:511) 05-09 18:46:57.254: e/androidruntime(25354):    @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:786) 05-09 18:46:57.254: e/androidruntime(25354):    @ com.android.internal.os.zygoteinit.main(zygoteinit.java:553) 05-09 18:46:57.254: e/androidruntime(25354):    @ dalvik.system.nativestart.main(native method) 

nullpointer exception @ onresumegame() method of basegameactivityclass.

i have added line in "activity" tag of manifest

 android:configchanges="orientation|keyboard|keyboardhidden" 

in gameactivity extends basegameactivity have added this

    @override     public void onpause() {       super.onpause();       mengine.stop();     }      @override     protected void onresume() {     // activity has become visible (it "resumed").        super.onresume();        mengine.start();     } 

what wrong? shall stop crashing game on power button issue?

whenever onresume() method called again recreate resources. @ time of onresume() method call controller not found mengine instance. because of fires error nullpointerexception.

the task of onpause() method stop music , sound , onresume() method again play sound , music. these methods not used other purpose in android game development particularly in andengine.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -