I want to invoke some receiver exactly on time, hence i am using alarm clock to set this using the following code. Everything works except on my screen and on top of the screen i see alarm icon and time. Similar to what u see when u set alarm using alarm clock app in android. I dont want to see this. How can i go about it?
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);
}
Before moving setAlarmClock
, i was using setExactAndAllowWhileIdle
, but setExactAndAllowWhileIdle
doesnot guarantee that it willl deliver event exactly on time. But it doesnot show the alarm icon on screen, which is what i want.
How can i go about it?
Don't use setAlarmClock()
. As the documentation states, "the system will typically also use the information supplied here to tell the user about this upcoming alarm if appropriate".