简体   繁体   中英

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

I have a BroadcastReceiver that is called when a GCM message arrives.
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.
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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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