Application.onLowMemory()不invloked [英] Application.onLowMemory() not invloked

查看:181
本文介绍了Application.onLowMemory()不invloked的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建自己的应用程序类。

I've create an Application class of my own.

我尝试调试它和code停止在Application.onCreate(),但不停止在onLowMemory。

I try to debug it and the code stops at Application.onCreate() but does not stop at onLowMemory.

要测试我打开了很多其他的高端内存的应用场景。

To test the scenario I open a lot of other high memory applications.

我看到的是,调试会话终止(在Eclipse)和我的一些静态变量转向空 - 表示该过程已经结束

What I see is that the debug session terminated (in eclipse) and some of my static variables turned to null - indicates the the process has ended.

不仅调试不会停止@方法的断点,我已经把Log.e(...)行并没有看到它。

Not only did the debug NOT stop @ the breakpoint of the method, I've put a Log.e(...) line and don't see it as well.

为什么不调用方法你知道吗?

Any idea of why the method was not invoked?

感谢。

推荐答案

我不认为有任何保证,这种方法都不会被调用。

I don't think that there are any guarantees that this method will ever be called.

文档

虽然确切点上本   将被称为没有被定义,   一般它会发生周围的   时间所有后台程序已经   杀了,那就是在到达前   点杀托管流程   服务和前台的用户界面,我们   想躲避查​​杀。

While the exact point at which this will be called is not defined, generally it will happen around the time all background process have been killed, that is before reaching the point of killing processes hosting service and foreground UI that we would like to avoid killing.

由于没有定义在它被称为点,它可以选择不调用它。

Since the point at which it is called is not defined, it could choose to never call it.

在一般情况下,Android是免费的杀你的应用程序,只要它想,只要它是在后台。您应该只依赖于生命周期方法(如在onPause,的onStop,的onDestroy),其明确说明,这样可以保证被调用,以便做必要的清理。

In general, Android is free to kill your Application whenever it wants, as long as it is in the background. You should only rely on methods in the lifecycle (like onPause, onStop, onDestroy) that specifically state that they are guaranteed to be called in order to do any necessary cleanup.

这篇关于Application.onLowMemory()不invloked的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆