I am running periodic background task using AlarmManager:
AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
Intent intent = new Intent(context, AlarmReceiver.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), 10 * 60 * 1000, pendingIntent);
I put a flag PendingIntent.FLAG_UPDATE_CURRENT
, but I afraid it re-writes my schedule if I run this code again. Questions:
- Will it reset the time and I'll have to wait for 10 mins to receive an event?
- Is there a way to check if my alarm task schedule is set?