检查其中的活动一直与QUOT的方式,鼓舞" [英] Checking the manner in which an Activity has been "reanimated"

查看:169
本文介绍了检查其中的活动一直与QUOT的方式,鼓舞"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将一个活动知道,如果它刚刚被带回无论从被最小化(例如,用户pressed家庭和做其他的东西,然后把应用程序返回到后来的前台),或从屏幕超时并且屏幕会黑?

How would an Activity know if it has just been brought back from either being minimized (e.g., the user pressed Home and did other stuff and then brought the app back into the foreground afterwards) or from the screen timing out and the screen going black?

如果我打了首页,而在一个应用程序,那么的OnDestroy不一定火,不是吗?也是一样的,如果屏幕超时。所以它似乎并不会有一种方法只要屏幕离开前景设置一个标志。

If I hit Home while on an app, then OnDestroy doesn't necessarily fire, does it? Same goes for if the screen times out. So it doesn't seem there will be a way to set a flag as soon as the screen leaves the foreground.

OnResume似乎火的时候,绝对不只是当一个活动被带回到前台。

OnResume seems to fire all the time, definitely not just when an Activity is brought back to the foreground.

看着LogCat中我看不到任何东西,给我任何提示,所以我在这里...

Watching LogCat I don't see anything that gives me any hints, so here I am...

推荐答案

我想这会解释你需要的一切: http://developer.android.com/reference/android/app/Activity.html

I think this will explain everything you need: http://developer.android.com/reference/android/app/Activity.html

但基本上是:在 onResume()活动时回来前景将永远火, 和的onPause()活动时被切换到后台(或损坏)将闪光。因此,覆盖两个就是答案。

But basically: the onResume() will always fire when the activity comes back to foreground, and the onPause() will fire when activity goes to background (or destroyed). So overriding both is the answer.

这篇关于检查其中的活动一直与QUOT的方式,鼓舞"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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