private void setFPAlarm()
{
Intent intent = new Intent(this, FPService.class);
PendingIntent pi = PendingIntent.getService(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
long nextSearchTimeMillis = DateUtils.MINUTE_IN_MILLIS/2;
Time nextSearchTime = new Time();
nextSearchTime.set(nextSearchTimeMillis);
AlarmManager FPAlarm = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
FPAlarm.setRepeating(AlarmManager.RTC, System.currentTimeMillis(), nextSearchTimeMillis, pi);
}
I use the above code to run IntentService every 30 seconds. Sometimes the maintenance process takes more than 30 seconds, so the other should start before the previous one is completed. I want to know what will happen to the previous one in this case. Is it paused? Does the second remain to wait for the completion of the previous one?
My second question: I do not want them to wait for each other. I want two services to start at the same time. Therefore, the next service should begin no matter what the previous one does. Is the above code the correct way to achieve this?
source
share