Android BroadcastReceiver Before Screen Off

136 Views Asked by At

Android Broadcast Receiver:

Is there any trick/event that can trigger just before screen is going to Off android.intent.action.SCREEN_OFF

OR

Any way to know if screen goes off by power press or by auto sleep function?

1

There are 1 best solutions below

0
On

Have you try to use de lifecycle methods? Every time the screen is Locked, the activity will call first the method onPause() and then onStop(), so you could override them to add your code