I'm using AlarmManager
for widget update transactions. I've different interval values like 5, 10, 15, 30 minutes etc.
How to call AlarmManager
:
alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
Intent i = new Intent(context, MyService.class);
pi = PendingIntent.getService(context, 0, i, PendingIntent.FLAG_UPDATE_CURRENT);
// Interval value, default 600 (600*1000 -> 10 min)
Long repeat = Long.parseLong(prefs.getString("update_preference", "600"));
// Set the manager
alarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP, Calendar.getInstance().getTimeInMillis(), 1000*repeat, pi);
So If user selects 5 or 10 minutes, it's okay. But if not, I mean, user selects bigger values like 15, 30, 60 minutes MyService
not working as soon as setRepetaing
.
What's difference or wrong?
Edit: It works instantly <30 minutes, but now work higher than 30 minutes with unique request codes.