AlarmManager:在某些设备上从最近的应用程序刷卡应用程序后,PendingIntent 消失了

Ale*_*ndr 5 android alarmmanager android-intent android-alarms

Simple demo GitHub project: https://github.com/Try4W/AlarmManagerDemo

On emulators(Android 4.1.1, Android 6):

  1. I scheduling new PendingIntent with AlarmManager
  2. check active alarms via adb shell dumpsys alarm
  3. see my Intent
  4. close app via swiping it from recent apps
  5. check active alarms via adb shell dumpsys alarm
  6. see my Intent
  7. BroadcastReciver fired at time!

On my device(LeTv One/Android 6):

  1. I scheduling new PendingIntent with AlarmManage
  2. check active alarms via adb shell dumpsys alarm
  3. see my Intent
  4. close app via swiping it from recent apps
  5. check active alarms via adb shell dumpsys alarm
  6. DO NOT see my Intent
  7. 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:

  1. set alarm via alarmManager.setAlarmClock(...)
  2. set alarm via setExactAndAllowWhileIdle(...)
  3. use intent-filter to execute BroadcastReciever
  4. set alarm from Service running in separated process

mar*_*mor 2

在某些(大多数)设备上,从最近使用的应用程序列表中滑动应用程序与从设置屏幕中Android滑动应用程序相同。force-closingApps

Android假设这意味着用户不希望从此应用程序进行任何活动,直到另行通知为止,这意味着由用户手动启动该应用程序。

请参阅:当应用程序强制关闭时,AlarmManager 不起作用