1

按下后退按钮后的日志:

11-07 22:48:08.376: D/AndroidRuntime(5325): 关闭 VM 11-07 22:48:08.376: W/dalvikvm(5325): threadid=1: 线程退出未捕获异常 (group=0x4162d700) 11 -07 22:48:08.384: E/AndroidRuntime(5325): 致命异常: main 11-07 22:48:08.384: E/AndroidRuntime(5325): java.lang.RuntimeException: 无法销毁活动

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

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

(ZygoteInit.java:739) 11-07 22:48:08.384: E/AndroidRuntime(5325): 在 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): 引起:java.lang.NullPointerException 11-07 22:48 :08.384: E/AndroidRuntime(5325): 在 com.some.pack.NY.stop(NY.java:100) 11-07 22:48:08.384: E/AndroidRuntime(5325): 在 com.some.pack。 onDestroy(NY.java:106) 11-07 22:48:08.384: E/AndroidRuntime(5325): 在 android.app.Activity.performDestroy(Activity.java:5302) 11-07 22:48:08.384: E/ AndroidRuntime(5325):在 android.app.Instrumentation.callActivityOnDestroy

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

(ActivityThread.java:3614) 11-07 22:48:08.384: E/AndroidRuntime(5325): ... 11 更多 11-07 22:48:08.392: W/ActivityManager(408): 强制完成活动 com.some .pack/.MainActivity 11-07 22:48:09.079:W/ActivityManager(408):ActivityRecord{41985990 u0 的活动暂停超时

com.some.pack/.MainActivity} 11-07 22:48:09.095:W/Settings(4780):设置 bugreport_in_power_menu 已从 android.provider.Settings.Secure 移至

android.provider.Settings.Global。11-07 22:48:09.095:E/Cryptfs(124):未运行加密,中止 11-07 22:48:09.923:I/Process(5325):发送信号。PID: 5325 SIG: 9 11-07 22:48:09.946: W/InputDispatcher(408): channel '419e2ff0 com.some.pack/com.some.pack.MainActivity (server)' ~ Consumer

关闭输入通道或发生错误。events=0x9 11-07 22:48:09.946: E/InputDispatcher(408): channel '419e2ff0 com.some.pack/com.some.pack.MainActivity (server)' ~ Channel is

不可恢复地破碎,将被处理!

4

2 回答 2

1

由于您没有发布日志,因此很难弄清楚,但您的实现中肯定存在巨大差距,将以 NullPointerException 结束,您正在点击侦听器中初始化“mp”和“mp2”,然后停止它们在 onDestroy 中,但是你没有在方法“stop”中检查空值,如果你去活动,这肯定会导致 NPE,并且不要按下播放按钮并将值分配给“mp 和 mp2”然后在按下时引用,并且调用 onDestroy (调用停止),CRASH!因为 mp 和 mp2 为空...

希望帮助。

问候!

于 2013-11-07T17:17:12.353 回答
0

在 onPrepared() onStop() onDestroy() 和 onCompletin() 中添加一个简单的 if 条件:

  if(mp != null && mp2 != null){
    // Now You wont get runTime problems.
  }
于 2013-11-08T05:01:08.100 回答