I have a notification being fired through AlarmManager and the notification also plays a sound.
Obviously, it may happen that the alarm is fired when the app is in the background, and I would like to let the user cancel the sound when pressing the lock button - i.e. listening for ACTION_SCREEN_OFF
.
Therefore I wonder if it's possible to start a service and listen for ACTION_SCREEN_OFF
?
I have seen Listening for ACTION_SCREEN_OFF but that solution of having a BroadCastReceiver only seems to work when the app is in the foreground. Right?