1

Logs after back button pressed:

11-07 22:48:08.376: D/AndroidRuntime(5325): Shutting down VM 11-07 22:48:08.376: W/dalvikvm(5325): threadid=1: thread exiting with uncaught exception (group=0x4162d700) 11-07 22:48:08.384: E/AndroidRuntime(5325): FATAL EXCEPTION: main 11-07 22:48:08.384: E/AndroidRuntime(5325): java.lang.RuntimeException: Unable to destroy activity

{com.some.pack/com.some.packNY}: java.lang.NullPointerException 11-07 22:48:08.384: E/AndroidRuntime(5325): at android.app.ActivityThread.performDestroyActivity

(ActivityThread.java:3627) 11-07 22:48:08.384: E/AndroidRuntime(5325): at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3645) 11-07 22:48:08.384: E/AndroidRuntime(5325): at android.app.ActivityThread.access$1200(ActivityThread.java:153) 11-07 22:48:08.384: E/AndroidRuntime(5325): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1322) 11-07 22:48:08.384: E/AndroidRuntime(5325): at android.os.Handler.dispatchMessage(Handler.java:99) 11-07 22:48:08.384: E/AndroidRuntime(5325): at android.os.Looper.loop(Looper.java:137) 11-07 22:48:08.384: E/AndroidRuntime(5325): at android.app.ActivityThread.main(ActivityThread.java:5289) 11-07 22:48:08.384: E/AndroidRuntime(5325): at java.lang.reflect.Method.invokeNative(Native Method) 11-07 22:48:08.384: E/AndroidRuntime(5325): at java.lang.reflect.Method.invoke(Method.java:525) 11-07 22:48:08.384: E/AndroidRuntime(5325): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run

(ZygoteInit.java:739) 11-07 22:48:08.384: E/AndroidRuntime(5325): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555) 11-07 22:48:08.384: E/AndroidRuntime(5325): at dalvik.system.NativeStart.main(Native Method) 11-07 22:48:08.384: E/AndroidRuntime(5325): Caused by: java.lang.NullPointerException 11-07 22:48:08.384: E/AndroidRuntime(5325): at com.some.pack.NY.stop(NY.java:100) 11-07 22:48:08.384: E/AndroidRuntime(5325): at com.some.pack.onDestroy(NY.java:106) 11-07 22:48:08.384: E/AndroidRuntime(5325): at android.app.Activity.performDestroy(Activity.java:5302) 11-07 22:48:08.384: E/AndroidRuntime(5325): at android.app.Instrumentation.callActivityOnDestroy

(Instrumentation.java:1117) 11-07 22:48:08.384: E/AndroidRuntime(5325): at android.app.ActivityThread.performDestroyActivity

(ActivityThread.java:3614) 11-07 22:48:08.384: E/AndroidRuntime(5325): ... 11 more 11-07 22:48:08.392: W/ActivityManager(408): Force finishing activity com.some.pack/.MainActivity 11-07 22:48:09.079: W/ActivityManager(408): Activity pause timeout for ActivityRecord{41985990 u0

com.some.pack/.MainActivity} 11-07 22:48:09.095: W/Settings(4780): Setting bugreport_in_power_menu has moved from android.provider.Settings.Secure to

android.provider.Settings.Global. 11-07 22:48:09.095: E/Cryptfs(124): not running with encryption, aborting 11-07 22:48:09.923: I/Process(5325): Sending signal. PID: 5325 SIG: 9 11-07 22:48:09.946: W/InputDispatcher(408): channel '419e2ff0 com.some.pack/com.some.pack.MainActivity (server)' ~ Consumer

closed input channel or an error occurred. events=0x9 11-07 22:48:09.946: E/InputDispatcher(408): channel '419e2ff0 com.some.pack/com.some.pack.MainActivity (server)' ~ Channel is

unrecoverably broken and will be disposed!

Alex Ironz
  • 13
  • 7

2 Answers2

1

Since you didn't post the logs, it's a little harder to figure out, but definitely there's a huge gap in your implementation which will end in a NullPointerException, you are initializing "mp" and "mp2" in a click listener, and stoping them in onDestroy, however you are not checking for null values in method "stop", which will definitely cause a NPE, if you go to the activity, and DO NOT Press the button that plays and assign values to the "mp and mp2" references then when pressing back, and onDestroy (which calls stop) is called, CRASH! because mp and mp2 are null...

Hope thos Helps.

Regards!

Martin Cazares
  • 13,637
  • 10
  • 47
  • 54
0

Add a simple if condition inside your onPrepared() onStop() onDestroy() and onCompletin():

  if(mp != null && mp2 != null){
    // Now You wont get runTime problems.
  }
amalBit
  • 12,041
  • 6
  • 77
  • 94