Dianne, since Service.setForeground() has been deprecated, what should
we use to stop a service being killed?

In particular, how should you keep a service alive that needs to
listen and respond to phone state events?

And on phone state events, why is it that responding to an inbound
phone call requires a phone state listener, but an outbound phone call
can be responded to via a broadcast receiver. Wouldn't it be better if
they both used the same mechanism?

On Aug 11, 12:10 pm, Dianne Hackborn <hack...@android.com> wrote:
> On Tue, Aug 10, 2010 at 5:41 PM, Streets Of Boston
> <flyingdutc...@gmail.com>wrote:
>
> > I have no empirical evidence for it, but i did notice that non-
> > foreground background services were being killed more aggresively. But
> > i could be mistaken.
>
> It could be more memory.  Oh and also there is now a limit on the maximum
> number of background processes we keep -- it turned out especially once all
> of the memory on the nexus one was available, for devices with large amounts
> of RAM we could keep around a fairly ridiculous number of processes. :)
>
> Services have for a number of releases been pushed into the background class
> after running for a while, to eventually get killed and restarted.  On
> devices like the Nexus One this could happen a bit more frequently.
>  However, for the last few releases it has been designed to basically
> guarantee that a background service will always get killed every now and
> then.
>
> If you are running a service that the user is aware of, you should use
> Service.startForeground().  One of the things this does is tell the system
> the user would not be happy if the service's process gets temporarily
> killed.  (Note that as of 2.0 Service.setForeground() is deprecated and has
> become a no-op.)
>
> --
> 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