Simple demo GitHub project: https://github.com/Try4W/AlarmManagerDemo
On emulators(Android 4.1.1, Android 6):
- I scheduling new
PendingIntent
withAlarmManager
- check active alarms via
adb shell dumpsys alarm
- see my
Intent
- close app via swiping it from recent apps
- check active alarms via
adb shell dumpsys alarm
- see my
Intent
- BroadcastReciver fired at time!
On my device(LeTv One/Android 6):
- I scheduling new
PendingIntent
withAlarmManage
- check active alarms via
adb shell dumpsys alarm
- see my
Intent
- close app via swiping it from recent apps
- check active alarms via
adb shell dumpsys alarm
- DO NOT see my
Intent
- BroadcastReciver not fired at all
If I add my app to 'protected apps' Intent
not removed after removing app from recent apps.
BUT! On my device AliExpress's app post notification without adding to 'protected apps'.
Note: alarm scheduled without problem on BOOT_COMPLETED
How did they achieve that?
What I already tried:
- set alarm via
alarmManager.setAlarmClock(...)
- set alarm via
setExactAndAllowWhileIdle(...)
- use intent-filter to execute
BroadcastReciever
- set alarm from
Service
running in separated process
On some (most)
Android
devices, swiping an app from the recents apps list is the same asforce-closing
it from theApps
settings screen.Android
assumes this means the user doesn't want any activity from this app until further notice, which means manually launching on the app by the user.See this: AlarmManager does not work when app is force closed