要求alarmManager不要在屏幕上和顶部显示闹钟时间和图标
Ask alarmManager not to display alarm time and icon on screen and on top
我想准时调用一些接收器,因此我使用闹钟来使用以下代码设置它。一切正常,除了在我的屏幕上,在屏幕顶部我看到闹钟图标和时间。类似于您在 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 所述,"the system will typically also use the information supplied here to tell the user about this upcoming alarm if appropriate"。
我想准时调用一些接收器,因此我使用闹钟来使用以下代码设置它。一切正常,除了在我的屏幕上,在屏幕顶部我看到闹钟图标和时间。类似于您在 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 所述,"the system will typically also use the information supplied here to tell the user about this upcoming alarm if appropriate"。