There is absolutely no benefit to keeping the service running during that
time.  If you want to avoid work when it starts every 5 minutes, keep your
previous work in static globals to re-use the next time the service is
created.  All you do by keeping the service running is that if the system is
running low on RAM it can't do as good a job at deciding which processes to
throw away, because you are not giving it good information about how
expendable your process is.

This also makes it more likely that in such a situation it will decide to
kill your process while it is actually actively doing stuff, because it will
think that the service has been sitting there running for a long time.
 Android considers long-running services to be better candidates to kill
than those that were more recently started.

On Wed, Jan 12, 2011 at 12:13 AM, mort <m...@sto-helit.de> wrote:

> On 11 Jan., 17:37, TreKing <treking...@gmail.com> wrote:
> > The likelihood of your Service running un-interrupted for 30 minutes,
> > especially if you're not running in the foreground, is extremely low.
>
> Well, if really necessary, one could show a notification and use
> startForeground.
>
> I for one would go for a compromise: Use AlarmManager for the timing,
> unless you really, really need to be as exact as possible (Android is
> a multitasking system, and services usually don't have highest
> priority, so there'll always be some lack). But don't stop the service
> until after the 30 minutes are over. This way, you only have to do all
> the initialization work if the system killed your service, while
> AlarmManager saves you from aborted updates and having to use wake
> locks while idle.
> I think for as short as 30 minutes it's OK to keep the service running
> mostly idle if this saves the system from having to load and
> initialize every 5 minutes. Esp. if this might be connected with
> restarting GPS and searching for sattellites again and again...
>
> --
> 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<android-developers%2bunsubscr...@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