开发者

Service and Wake Lock Policy

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/A开发者_Go百科larm/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?


So my question is, will a service allow the CPU to sleep if it does not have a wake policy running through the service?

Of course. Think of a laptop that sleeps when one closes its lid (the silly default). Some method somewhere will be interrupted - be it the main() method of the currently running application

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜