+1 vote
by
alarmManager = (AlarmManager) gcontext.getSystemService(gcontext.ALARM_SERVICE);
alarmManager.setRepeating(
AlarmManager.ELAPSED_REALTIME_WAKEUP,
System.currentTimeMillis(),
SystemClock.elapsedRealtime() + DB.getServiceRepeatTime(),
pendingIntent);
There is a service which reads the period run from the database. In order for the service to function with the new range, I store the new value in database and restart service. after you restart the AlarmManager for the first time triggered in 30 seconds, and then enters the desired interval. Why is the first operation occurs in 30 seconds?

1 Answer

0 votes
by
What version of the sdk? Carefully read the java doc to the AlarmManager - the fact that starting from version > 19 - there is no guarantee that AlarmManager will work exactly in the time that you have.
"Note:as of API 19, all repeating alarms are inexact. If your
* application needs precise delivery times then it must use one-time
* exact alarms, rescheduling each time as described above."
This is from javadoc
I hope that I correctly understood the question
...