Search code examples
androidbroadcastreceiver

How to know that my app is in foreground on screen unlock


Every-time i want to show an add screen after screen unlock on only if my application is in running sate i mean foreground (User currently uses it). I done this through

"user_present permission and the receiver"

Its working fine on screen unlock. But the problem is it always shows me add screen. Either my app is in foreground(ON) or is in background(OFF).


Solution

  • The only thing I can think of is to have a broadcast receiver for the screen unlock event (details at Activity handle when screen unlocked) and once this broadcast is received it opens up the screen you want.