如何检测屏幕是否开启或关闭,如果API级别为4? [英] How to detect whether screen is on or off if API level is 4?
本文介绍了如何检测屏幕是否开启或关闭,如果API级别为4?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道如何检测屏幕变暗或亮度在Android 1.6。
I am wondering to know how to detect screen dim or brightness on Android 1.6.
我发现在API级别7的解决方案是容易的开发:
I've found a solution on API Level 7. It is easy to develop :
PowerManager pm = (PowerManager)
getSystemService(Context.POWER_SERVICE);
boolean isScreenOn = pm.isScreenOn();
但我需要为Android 1.x的一个解决方案。
But I need a solution for Android 1.x.
您可以给我建议?
感谢。
推荐答案
有关屏幕开关状态,你可以用 ACTION_SCREEN_ON
和 ACTION_SCREEN_OFF尝试
意图
S,如下面的博客文章:http://thinkandroid.word$p$pss.com/2010/01/24/handling-screen-off-and-screen-on-intents/
For screen on-off state, you can try with ACTION_SCREEN_ON
and ACTION_SCREEN_OFF
Intent
s, as shown in this blog post: http://thinkandroid.wordpress.com/2010/01/24/handling-screen-off-and-screen-on-intents/
这篇关于如何检测屏幕是否开启或关闭,如果API级别为4?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文