使用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);

其中alarmDateTime是包含警报日期和时间的LocalDateTime对象。 在Android M和N(实际设备)上,一旦设置了闹钟,状态栏上就会出现一个闹钟符号。但是在我的三星galaxy M31s(Android Q)上,没有出现警报信号!但是当我在Android Q模拟器上运行该应用程序时,便会出现闹钟迹象。

在Samsung 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}}

这就是我想要的。这样便设置了警报,并且确实会响起警报,但是没有出现警报标志。

出什么问题了?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)