why in the API Demo's AlarmService_Service.java, it says“just sleep for 30 seconds” instead of 15 seconds?

空扰寡人 提交于 2019-12-11 15:32:56

问题


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:


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.



来源:https://stackoverflow.com/questions/9146647/why-in-the-api-demos-alarmservice-service-java-it-saysjust-sleep-for-30-secon

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!