why in the API Demo's AlarmService_Service.jav

2019-08-18 06:11发布

I just looked through the AlarmService sample in the Android API Demo(API 8).

When the AlarmManager in the AlarmService.java file use setRepeating() method to schedule the 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 it says "we will just sleep for 30 seconds."? My understanding is: the thread starts, and it waits/sleeps for 15 seconds(NOT 30 seconds), then this thread will be stop by calling the stopSelf() method. So it will sleep 15 seconds instead of 30, right? Am I missing something?

Any Hints?

Thanks in advance:)

1条回答
爷、活的狠高调
2楼-- · 2019-08-18 06:17

People make mistakes. Despite my little experience with Android Development, it seems like it is a mistake.

Of course, the real way to find out is to use a stopwatch while running the code.

查看更多
登录 后发表回答