简体   繁体   English

Android:完成一个非常短的任务是否需要WakeLock?

[英]Android: Do I need a WakeLock for a really short task?

I have a BroadcastReceiver that is called when a GCM message arrives. 我有一个当GCM消息到达时被调用的BroadcastReceiver。
All it does is that it sets an "update on next app start"-flag in the shared preferences, and pushes a notification. 它所做的就是在共享首选项中设置“下一个应用程序启动时更新”标志,并推送通知。
So far, I haven't encountered a problem without a WakeLock, and I would like to keep app permissons as few as possible. 到目前为止,没有WakeLock,我还没有遇到任何问题,我想尽可能减少应用程序的权限。
Is it likely, that the device will go back to sleep during this millisecond process? 在这毫秒的过程中,设备是否有可能重新进入睡眠状态?

If that's all your doing, then you don't need a WakeLock . 如果这是你所有做的,那么你就不需要激活锁定 If you were doing a bigger task that took more time then you should use a service, if it's only a few seconds (less in your case) you can go without it. 如果您要完成一项耗时较长的较大任务,则应使用一项服务,如果只有几秒钟(在您的情况下较少),则可以不用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM