开发者

Android stay app active

I would like to stay my android application active when it working, and I am using FLAG_KEEP_SCREEN_ON flag for this purpose, but I don't want always keep screen on, because it's not economic for battery. I want to use a standard behavior - when user touch screen - he's lighting up, and after some time of inactive turn off. How can I 开发者_开发技巧do this?


I suggest looking at PowerManager.WakeLock, in particular the PowerManager.PARTIAL_WAKE_LOCK flag, this will keep the CPU running yet let the screen turn off. If you take this approach, make sure you release the WakeLock when you are done with it.

You can find out more about it here: http://developer.android.com/reference/android/os/PowerManager.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜