android - 使用 AlarmManager#setAlarmClock 安排闹钟时,Android 10 中没有闹钟登录
问题描述
我的应用程序是一个闹钟应用程序,我通过以下方式设置闹钟:
PendingIntent pendingIntent = PendingIntent.getBroadcast(Activity_AlarmsList.this, alarmID, intent, 0);
ZonedDateTime zonedDateTime = ZonedDateTime.of(alarmDateTime.withSecond(0), ZoneId.systemDefault());
alarmManager.setAlarmClock(new AlarmManager.AlarmClockInfo(zonedDateTime.toEpochSecond() * 1000, pendingIntent), pendingIntent);
wherealarmDateTime
是一个LocalDateTime
包含警报日期和时间的对象。在 Android M 和 N(真实设备)上,一旦设置了闹钟,状态栏上就会出现闹钟标志。但在我的三星 Galaxy M31s (Android Q) 上,没有出现警报信号!但是当我在 Android Q 模拟器上运行应用程序时,会出现闹钟标志。
在三星 Galaxy M31s 中,如果我执行adb shell dumpsys alarm
,我会得到以下输出:
Next wake from idle: Alarm{c9c59a type 0 when 1603225320000 in.basulabs.shakealarmclock}
tag=*walarm*:in.basulabs.shakealarmclock.DELIVER_ALARM
type=0 expectedWhenElapsed=+48s986ms expectedMaxWhenElapsed=+48s986ms whenElapsed=+48s986ms maxWhenElapsed=+48s986ms when=2020-10-21 01:52:00.000
window=0 repeatInterval=0 count=0 flags=0x3
Alarm clock:
triggerTime=2020-10-21 01:52:00.000
showIntent=PendingIntent{f26a278: PendingIntentRecord{9c3ed51 in.basulabs.shakealarmclock broadcastIntent}}
operation=PendingIntent{860e9b6: PendingIntentRecord{9c3ed51 in.basulabs.shakealarmclock broadcastIntent}}
这就是我想要的。就这样定了闹钟,果然闹钟也响了,但是没有闹钟的标志出现。
问题是什么?
解决方案
推荐阅读
- python-3.x - 从 PKS 文件中获取 python signxml 的证书和密钥
- php - PHP URL隐藏类别的ID
- typescript - 在 TypeScript 中定义类型之间的相等性
- android - Android Gravity Left vs Right Clipping 差异
- python - 如何获取维基项目的维基百科数据?
- html - Favicon error 404 for local and remote, favicon.ico directory automatically generated in git repo
- microsoft-teams - How to get webHookUrl from Microsoft Teams connector
- google-cloud-firestore - Google Cloud Firestore 控制台读取所有文件和费用
- java - Java中try catch块中可捕获异常的规则是什么?
- django - 我无法删除 Django 应用程序中的包,因为它存储在迁移文件中