我想准时调用一些接收器,因此我使用闹钟来使用以下代码设置它。一切正常,除了在我的屏幕上,在屏幕顶部我看到闹钟图标和时间。类似于您在 android 中使用闹钟应用程序设置闹钟时看到的内容。我不想看到这个。我该怎么做?
private static void updateNextAlarmInAlarmManager(Context context, long nextAlarmTime) {
// Sets a surrogate alarm with alarm manager that provides the AlarmClockInfo for the
// alarm that is going to fire next. The operation is constructed such that it is ignored
// by AlarmStateManager.
final AlarmManager alarmManager = (AlarmManager) context.getSystemService(ALARM_SERVICE);
final int flags = 0;
final PendingIntent operation = PendingIntent.getBroadcast(context, 0 /* requestCode */,
createIndicatorIntent(context), flags);
final AlarmManager.AlarmClockInfo info = new AlarmManager.AlarmClockInfo(nextAlarmTime, getPendingIntentForApp(context, nextAlarmTime));
alarmManager.setAlarmClock(info, operation);
}
在移动 setAlarmClock
之前,我正在使用 setExactAndAllowWhileIdle
,但是 setExactAndAllowWhileIdle
不保证它会准时交付事件。但它没有在屏幕上显示警报图标,这正是我想要的。
最佳答案
How can i go about it?
不要使用 setAlarmClock()
。作为the documentation状态,“系统通常还会使用此处提供的信息来告知用户即将到来的警报(如果适当的话)”。
关于android - 要求alarmManager不要在屏幕上和顶部显示闹钟时间和图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53796540/