本文介绍了为什么API演示的AlarmService_Service.java中,它说:"刚从睡眠状态30秒"代替15秒?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是通过在Android API演示(API 8)AlarmService样品看去。

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

在()的AlarmManager在AlarmService.java文件使用setRepeating方法来安排报警,该服务将在AlarmService_Service.java文件中创建一个新的线程。

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.

我的问题是:

在mTask Runnable对象,所以才说:我们只是睡了30秒的run()方法?我的理解是:线程启动,并等待/调用stopSelf()方法休眠15秒(不是30秒),则该线程将被停止。因此,它会休眠15秒,而不是30,是吧?我缺少的东西吗?

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?

任何提示?

在此先感谢:)

推荐答案

人犯错误。尽管我与Android开发经验不多,现在看来似乎是一个错误。

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

当然,要找出真正的方法是使用一个秒表运行code,而

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

这篇关于为什么API演示的AlarmService_Service.java中,它说:"刚从睡眠状态30秒"代替15秒?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 17:35