I just looked at the AlarmService sample in the Android API Demo (API 8).
When the AlarmManager in the AlarmService.java file uses the setRepeating () method to schedule an alarm, the service will create a new thread in the AlarmService_Service.java file.
My question is:
In the run () method of the mTask Runnable object, why does it say "we'll sleep 30 seconds"? I understand: the thread starts and it waits / sleeps for 15 seconds (not 30 seconds), then this thread will be stopped by calling the stopSelf () method. That way he will sleep 15 seconds instead of 30, right? Did I miss something?
Any clues?
Thanks in advance:)
Evan_HZY
source share