如何检测当屏幕上? [英] How to detect when the screen is on?

查看:120
本文介绍了如何检测当屏幕上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如前面提到的previous的问题,我有困难拦截所有 android.intent.action.SCREEN_ON 事件没有一个长寿命服务(灰心)。

As mentioned in a previous question, I am having difficulty intercepting all android.intent.action.SCREEN_ON events without a long-lived Service (discouraged).

我可能能够解决,需要的话我可以简单地计算出当屏幕上在任何时候,在服务

I may be able to work around the need if I can simply work out when the screen is on at any given time, in the Service.

任何人都可以表明一个方法调用,将返回这一信息? 1.5以上。

Can anyone suggesting a method call that would return this information? 1.5 upwards.

推荐答案

系统故意不允许应用程序接收 ACTION_SCREEN_ON ACTION_SCREEN_OFF 在其清单广播,因为我们非常不希望有发射一束应用程序的打开屏幕或关闭。这是发生的事情的所有的时间,并且必须尽可能地快。

The system deliberately doesn't allow applications to receive ACTION_SCREEN_ON and ACTION_SCREEN_OFF broadcasts in their manifest, because we very much do not want to have to launch a bunch of apps to turn the screen on or off. This is something that happens all of the time, and must be as fast as possible.

不幸的是,如所指出的,没有办法立即检查,看是否在屏幕上。

Unfortunately, as pointed out, there isn't a way to check immediately to see if the screen is on.

这篇关于如何检测当屏幕上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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