2

As stated by the AlarmManager docs:

http://developer.android.com/reference/android/app/AlarmManager.html#RTC_WAKEUP

This means that the phone will in some cases sleep as soon as your onReceive() method completes. If your alarm receiver called Context.startService(), it is possible that the phone will sleep before the requested service is launched. To prevent this, your BroadcastReceiver and Service will need to implement a separate wake lock policy to ensure that the phone continues running until the service becomes available.

From what I've seen and read here: http://www.androidguys.com/2009/04/02/wake-up-with-the-alarm/ https://github.com/commonsguy/cw-advandroid/blob/master/SystemServices/Alarm/src/com/commonsware/android/syssvc/alarm/WakefulIntentService.java

That guys holds onto the wake lock through the service not just until it becomes available. So my question is, will a service allow the CPU to sleep if it does not have a wake policy running through the service?

4

1 回答 1

0

所以我的问题是,如果服务没有通过服务运行唤醒策略,它会允许 CPU 休眠吗?

当然。想象一台笔记本电脑在合上盖子时会进入睡眠状态(愚蠢的默认设置)。某处的某些方法将被中断 - 无论是当前正在运行的应用程序的 main() 方法

于 2013-11-15T00:17:32.897 回答