服务和唤醒锁政策
正如 AlarmManager 文档所述:
http://developer.android.com/参考/android/app/AlarmManager.html#RTC_WAKEUP
这意味着在某些情况下,一旦 onReceive() 方法完成,手机就会进入睡眠状态。如果您的警报接收器调用 Context.startService(),则手机可能会在启动请求的服务之前休眠。为了防止这种情况,您的 BroadcastReceiver 和服务需要实施单独的唤醒锁定策略,以确保手机继续运行直到服务可用。
从我在这里看到和读到的: http://www.androidguys.com/2009/ 04/02/闹钟叫醒/ https://github.com/commonsguy/cw-advandroid/blob/master/SystemServices/Alarm/src/com/commonsware/android/syssvc/alarm/WakefulIntentService.java
那家伙持有唤醒锁 服务,而不仅仅是直到服务变得可用。所以我的问题是,如果服务没有通过服务运行唤醒策略,它是否会允许 CPU 休眠?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当然。想象一下一台笔记本电脑,当合上盖子时就会进入睡眠状态(愚蠢的默认设置)。某处的某些方法将被中断 - 无论是当前正在运行的应用程序的 main() 方法
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