开发者

android.intent.action.SCREEN_OFF

开发者 https://www.devze.com 2023-01-10 04:12 出处:网络
I am trying to detect Screen backlight On / Off. I\'ve found android.intent.action.SCREEN_OFF related its event.

I am trying to detect Screen backlight On / Off.

I've found android.intent.action.SCREEN_OFF related its event.

But I don't know how to use this.

Can you suggest me about how to detect screen backlight on / off ?

开发者_StackOverflowI missing some example or sample code.

Thanks in advance.


If you still need to use a BroadCastReceiver, you have to register it in code using the registerReceiver(receiver, filter) on one of your Activities.

The intents do not fire if you register them in the Manifest.


Create a BroadCastReciever, Add an Intent Filter including your Intent (android.intent.action.SCREEN_OFF).

Just Override the OnRecieve function in the BroadcastReciver with your code.

Be Sure to include the BroadcastReciever in the Manifest File!

good luck! :)


I think you can have a look at this class. The method isScreenOn() might be what you need.

0

精彩评论

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