
并不总是调用onDestroy().如果被调用,则只执行部分代码.
而且大部分时间在LogCat中我只看到消息“首先调用destroy的gps状态”.这是为什么?
protected voID onDestroy(){ super.onDestroy(); Log.d("on destroy called", "gps state on destroy called first"); editor.putBoolean("gpsOn", false); Log.d("on destroy called", "gps state on destroy called second"); editor.commit(); Log.d("on destroy called", "gps state on destroy called third"); stopRouteTracking(); Log.d("on destroy called", "gps state on destroy called fourth"); }解决方法:
看看这个:
Activity OnDestroy never called?
还有这个:
http://developer.android.com/reference/android/app/Activity.html#onDestroy%28%29
基本上,从来没有保证会调用onDestroy(),在某些情况下,你的应用程序等进程将被直接杀死,无论如何都会绕过方法调用.
总结以上是内存溢出为你收集整理的Android Activity onDestroy()并不总是被调用,如果被调用,则只执行部分代码全部内容,希望文章能够帮你解决Android Activity onDestroy()并不总是被调用,如果被调用,则只执行部分代码所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)