Nikhil:

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.

It seems backwards at first.  The Android just has some seriously Diligent
GC!  In most technologies, you just never erase/clear something and handle
your own GC or don't if there's not a reason to.  W/ Android, if you don't
ever have a release() command, it auto-releases it.  But, you can put one in
and bury it where it will never get called and it won't release it!  Sounds
backwards right?  Don't put in a release command and it releases it; put in
a release command, and it won't!  But it works!

Thanks,
Nick Owens
VP, ThreeClix
Office: (904) 429-7039
Mobile: (847) 565-9392
After Hours: (904) 540-5830


-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of nikhil
Sent: Friday, February 19, 2010 1:28 PM
To: Android Developers
Subject: [android-developers] Re: WakeLock finalized while still held?

I am doing similar stuff and I  hold on to the Partial WakeLock inside
the onCreate method and release it onDestroy. When I tried to hold the
wakelock anywhere outside onCreate my service died out.
Also I have made my servive a foreground service. Everything works
fine now. Are you doing similar stuff?

The only problem I encounter now is that my app is having some
conflict with google's car home app (GPS navigation).

On Feb 18, 11:34 pm, Nick Owens <[email protected]> wrote:
> For the experts listening...
>
> I have a background service running and I sometimes, but not always,
> receive the following error when clicking on a notification, which
> opens the main App activity.
>
> WakeLock finalized while still held
>
> In my search for an answer, I read the post below:
>
> http://www.mail-archive.com/[email protected]/msg160...
>
> While it appears to make sense technically, it doesn't work for this
> app.  Like scanning for voicemail, this background service needs to
> constantly, and forever, stay alert - checking the server every few
> minutes for notifications.
>
> So my questions are:
>
> 1.) Why is GC coming after my WakeLock (or is after my service?), just
> b/c someone clicked on a notification it launched?
>
> 2.) Can I prevent GC from messing w/ my PowerManager object and my
> service?
>
> 3.) is there a way to have the service running indefinitely w/ an
> indefinite WakeLock?
>
> I understand the answer, if there is a sutiable one, probably doesn't
> fit most apps out there.  For that reason, it may not even make sense
> to provide the answer, since every user from here on out will be able
> to find it and leave their services running indefinitely.  But I need
> to, so please email me privately if you can.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to