Hello.

I too have a Service. It performs a task, and when finished, it
releases the wake-lock. There is a place to stop the service from
doing its work, and at this point I too release the wake-lock. So from
my perspective, I cleanly release the wakelock at all possible exit
points from my service.

 Yet every 250,000 monkey events or so....eg 3+ hours of testing, I
get a "Wake-lock finalized while still held exception". This irks me.

I don't see a benefit of your wakeful intent service. 2 differences
between it and my service is that it uses the synchronized keyword on
the getLock, and it makes the wakelock a static member (mine is a
class member) I don't see how either of these this would affect my
situation.


If I'm cleanly releasing the wakelock every time the service is
finished with its work....then where is wakelock exception being
thrown... from research, it would seem as if the service is killed
randomly, dirtily.

So...assuming this exception is thrown when the service is being ultra
hard kill-9 . Otherwise... I'm really looking for a faster way to
reproduce my bug, any ideas??



On Feb 20, 1:48 am, Mark Murphy <mmur...@commonsware.com> wrote:
> Starting from the beginning:
>
> >> Like scanning for voicemail, this background service needs to
> >> constantly, and forever, stay alert - checking the server every few
> >> minutes for notifications.
>
> Scanning for voicemail would not do that, and neither should your app.
>
> Please read this:
>
> http://www.androidguys.com/2009/09/09/diamonds-are-forever-services-a...
>
> and this:
>
> http://www.androidguys.com/2009/12/07/code-pollution-boot-time-services/
>
> and watch this:
>
> http://www.youtube.com/watch?v=OUemfrKe65c
>
> and then switch to use an IntentService, perhaps a WakefulIntentService,
> triggered by AlarmManager. The advantage of WakefulIntentService is that
> it will hold aWakeLockonly as long as is needed to do your work,
> allowing the CPU to go back to sleep, ensuring maximal battery life.
>
> WakefulIntentService can be found here:
>
> http://github.com/commonsguy/cwac-wakeful
>
> >> 3.) is there a way to have the service running indefinitely w/ an
> >> indefiniteWakeLock?
>
> No.
>
> > I did figure it out.  I had mine being created in onStart().  I now declared
> > it as a class field, create in on onCreate() and release it in onDestroy().
> > Funny thing, it never gets released this way.
>
> Not releasing aWakeLockis just asking for users to march on your
> office, brandishing torches and pitchforks. Please reconsider.
>
> --
> Mark Murphy (a Commons 
> Guy)http://commonsware.com|http://twitter.com/commonsguy
>
> _The Busy Coder's Guide to Android Development_ Version 2.9
> Available!

-- 
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