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.
精彩评论