Re: [android-developers] Multiple applications with WakeLock vs. one WakeLock app
You need to hold a wake lock for any duration when you need to make sure the CPU doesn't go into deep sleep. It doesn't matter what other applications are doing, for your code to be correct you need to hold the wake lock when your code relies on the CPU being kept running, so the platform knows about this requirement.
If other apps are sitting around holding wake locks all the time, they are also sitting there and draining your battery. Personally I wouldn't want to have such apps on my device.
Also it makes no sense to talk about the user deciding when wake locks should be held. The user decides when they want the screen to be on... and yes, implicitly, when the screen is on the CPU is kept awake. But when the screen is off, it would be crazy to have the user doing something to the device every 5 minutes or however often they think the CPU should wake up in order to do some work.
When the screen is off, the CPU is only kept running as long as someone is holding a wake lock to say it needs to be running. You should only hold a wake lock for as little time as possible, because all the time you are holding it is time you are allowing the battery to be drained, often significantly more than it would be otherwise. And your actions here will show up to the user in the battery use UI so they know who to blame for killing their battery.
When the screen is off, the CPU is only kept running as long as someone is holding a wake lock to say it needs to be running. You should only hold a wake lock for as little time as possible, because all the time you are holding it is time you are allowing the battery to be drained, often significantly more than it would be otherwise. And your actions here will show up to the user in the battery use UI so they know who to blame for killing their battery.
On Sun, May 13, 2012 at 2:51 PM, William Kelley <williamtkelley@gmail.com> wrote:
I am developing a simple GPS logger that runs as a service, getting fixes in short intervals. As I've read documentation and posts in this forum, I realize I need a WakeLock to keep the service running and logging points. Right now, without a WakeLock, my service runs fine for many hours, even when I am not using the phone that entire period. This is because I have other apps installed (task automation, etc.) that are using WakeLocks.
So, a couple of questions. Are there any issues running multiple apps that all use WakeLocks? Aren't they all just redundant? Wouldn't it be smarter to have one WakeLock app installed (at least one exists in the market) that allows the user to decide how and when to let the CPU/screen sleep and wake? In that way, WakeLock support doesn't need to be added to multiple applications.
I'm not trying avoid implementing WakeLock, just want to make sure it's the best solution.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
Dianne Hackborn
Android framework engineer
hackbod@android.com
Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them.
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home