好象叫只执行部分的code

好象叫只执行部分的code

本文介绍了安卓活动的onDestroy()并不总是打来电话,好象叫只执行部分的code的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

的onDestroy()并不总是被调用。如果调用,执行的code的一部分。
和大多数在LogCat中的时候,我只看到消息上摧毁GPS状态,被称为第一次。这是为什么呢?

 保护无效的onDestroy(){
    super.onDestroy();
    Log.d(关于灭称为,GPS状态上摧毁被称为第一次);

    editor.putBoolean(gpsOn,假);
    Log.d(关于灭称为,GPS状态上摧毁所谓的第二);
    editor.commit();

    Log.d(关于灭称为,GPS状态上摧毁所谓第三);
    stopRouteTracking();
    Log.d(关于灭称为,GPS状态上摧毁所谓的第四次);





}
 

解决方案

看看这个:

活动的OnDestroy从来不叫?

和这样的:

基本上,从未有保证,的onDestroy()将被调用,并在某些情况下,如你的应用程序将被直接打死,反正绕过方法调用。

onDestroy() is not always called. If called, only part of the code is executed.
And most of the time in LogCat I only see the message "gps state on destroy called first". Why is that?

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");





}
解决方案

Take a look at this:

Activity OnDestroy never called?

And this:

http://developer.android.com/reference/android/app/Activity.html#onDestroy%28%29

Basically, there's never a guarantee that onDestroy() will be called, and in some cases processes such as your app will be killed directly, bypassing the method call anyway.

这篇关于安卓活动的onDestroy()并不总是打来电话,好象叫只执行部分的code的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 21:40