AlarmManager:从某些设备上的最新应用程序中刷出应用程序后,PendingIntent消失了 [英] AlarmManager: PendingIntent gone after swiping app from recent apps on some devices
问题描述
简单的GitHub演示项目: https://github.com/Try4W/AlarmManagerDemo
Simple demo GitHub project: https://github.com/Try4W/AlarmManagerDemo
在模拟器上(Android 4.1.1,Android 6):
On emulators(Android 4.1.1, Android 6):
- 我使用
AlarmManager
安排新的 - 通过
adb shell dumpsys警报
检查活动警报 - 查看我的
Intent
- 通过从最近的应用程序中刷卡来关闭应用程序
- 通过
adb shell dumpsys警报
检查活动警报 - 查看我的
意图
- BroadcastReciver触发了!
PendingIntent
- 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!
在我的设备上(LeTv One/Android 6):
On my device(LeTv One/Android 6):
- 我使用
AlarmManage
安排新的 - 通过
adb shell dumpsys警报
检查活动警报 - 查看我的
Intent
- 通过从最近的应用程序中刷卡来关闭应用程序
- 通过
adb shell dumpsys警报
检查活动警报 - 看不到我的
Intent
- BroadcastReciver根本没有触发
PendingIntent
- 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
如果我将应用程序添加到受保护的应用程序"中,则从最近的应用程序中删除应用程序后未删除 Intent
.
If I add my app to 'protected apps' Intent
not removed after removing app from recent apps.
但是!在我的设备上,AliExpress的应用程序发布通知未添加到受保护的应用程序"中.
BUT! On my device AliExpress's app post notification without adding to 'protected apps'.
注意:在 BOOT_COMPLETED
他们是如何实现的?
我已经尝试过的:
- 通过
- 设置警报通过
setExactAndAllowWhileIdle(...)
- 设置警报
- 使用意图过滤器执行
BroadcastReciever
- 在单独的进程中运行的
Service
设置警报
alarmManager.setAlarmClock(...)
- set alarm via
alarmManager.setAlarmClock(...)
- set alarm via
setExactAndAllowWhileIdle(...)
- use intent-filter to execute
BroadcastReciever
- set alarm from
Service
running in separated process
推荐答案
在某些(大多数) Android
设备上,从最近使用的应用程序"列表中滑动应用程序与 force-closesing相同.
在 Apps
设置屏幕上
On some (most) Android
devices, swiping an app from the recents apps list is the same as force-closing
it from the Apps
settings screen.
Android
假定这意味着用户不需要该应用程序进行任何活动,直到另行通知,这意味着用户在该应用程序上手动启动了该应用程序.
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.
查看此内容:在强制使用应用程序时,AlarmManager不起作用关闭
这篇关于AlarmManager:从某些设备上的最新应用程序中刷出应用程序后,PendingIntent消失了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!