In one of the exemptions of the "cannot start foreground service from background" restriction, the doc mentions:
Your app invokes an exact alarm to complete an action that the user requests.
Does this mean that the usage scenario below can work?
Use
AlarmManager.setAlarmClockto schedule an exact alarm to trigger at time A. The alarm carries apendingIntentthat targets a registered broadcast receiver.Time A hits, the receiver gets the intent.
In the receiver
OnCreatemethod, we attempt tostartForegroundServicewhich involves displaying a sticky notification and playing custom music withMediaPlayer.