My question wasn't about battery life, but I'll address it anyway. Users 
who install apps that use long running services are usually fully aware 
that it will affect battery life. Certainly anyone who wants to record a 
GPS track for a few hours with very fine resolution (points every 5 seconds 
say) knows it will kill the battery quickly. But the point is they know 
this and want these apps regardless. You may not personally have a use for 
such services, but others do. My phone wouldn't be interesting, to me, if 
the only thing I focused on was plugging the phone in no more than once a 
day. I have no problem recharging several times a day (especially all the 
time I am driving) so that I can use my phone as a sensor and logger and 
record interesting information. This requires battery, but it is 
information I want.

The question I was trying to ask in this post was really more partly 
practical and partly conceptual. Practically, are there any issues with 
having multiple apps on your phone each implementing their own WakeLocks? I 
currently have three and they don't seem to interfere with each other. 
Which brings me to the question of whether I should implement a WakeLock in 
my own GPS logger app despite the fact I know my phone will never sleep the 
CPU? Now for any potential users of my apps (if I were to release it), I 
would then tell them they had to get a WakeLock app (there is one on the 
market) in order to keep the CPU awake so that my GPS logger will continue 
to record points as long as they like. That may be too much to require of a 
user and implementing my own WakeLock is the easiest solution. But 
conceptually, it seems redundant that every app that wishes to have a long 
running service would have to have its own WakeLock, when only one is 
required. That's why, at least for me and users like me, one WakeLock app 
to rule them all makes a lot of sense.

As for the user, I don't think it's "crazy" at all for them to want to 
control how their phone works. Again, if the user wants the features of 
long running services, why dissuade them? Letting the user choose to have 
the CPU running at all times (partial wake lock) seems completely 
reasonable.


On Sunday, May 13, 2012 3:49:21 PM UTC-7, Dianne Hackborn wrote:
>
> 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.
>
> On Sun, May 13, 2012 at 2:51 PM, William Kelley 
> <williamtkel...@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+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/android-developers?hl=en
>
>
>
>
> -- 
> Dianne Hackborn
> Android framework engineer
> hack...@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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to