Simple demo GitHub project: https://github.com/Try4W/AlarmManagerDemo
On emulators(Android 4.1.1, Android 6):
- I scheduling new
PendingIntentwithAlarmManager - 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
PendingIntentwithAlarmManage - 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
Servicerunning in separated process
On some (most)
Androiddevices, swiping an app from the recents apps list is the same asforce-closingit from theAppssettings screen.Androidassumes 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