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-are-not/

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 a WakeLock only 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
>> indefinite WakeLock?

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 a WakeLock is 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 [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