The  service will be at the level of the most important thing it is doing.
 If it has a service that is started, and an application that is in the
foreground bound to it, then it will be in the foreground as long as any
such bound application is foreground.  When the application goes to the
background, it will be lowered to the service level (unless there is some
other component or something else going on more important than the service).

This is very different than just making a long running thread in the
processes, which the system then doesn't know about and never prioritizes
the process based on the thread being there.  (And anyway you can't bind to
a thread from another processes, so functionally you just can't do the same
things.)

Also please realize that just having a service started doesn't mean your
process won't get killed except under unusual situations.  In fact the
current implementation ensures that, for a service that remains started a
long time, its process will eventually get killed (and the service then
restarted).

On Sat, Mar 5, 2011 at 8:30 AM, pedro242 <[email protected]>wrote:

> (Great! An answer from the
> prestigious M.Murphy!! Great books!!)
>
> Thanks Mark for your answer..
>
> But the Services in "bound" mode are still not clear for me..
>
> Android Doc says:
> "If there are clients bound to the service, then the service's hosting
> process is never less important than the most important client. That
> is, if one of its clients is visible to the user, then the service
> itself is considered to be visible. "
>
> So if my most important client gets stopped and goes in the background
> (or even worse, is destroyed), the Service process is then ranked in
> the same way??  wich means most likely to be also destroyed..
> That is my real concern..
>
> Mark, do you confirm my understanding?
>
>
> On Mar 5, 3:40 pm, Mark Murphy <[email protected]> wrote:
> > On Tue, Mar 1, 2011 at 2:06 PM, pedro242 <[email protected]>
> wrote:
> > > When the Service is started, the Android doc is quite clear saying:
> > > "If the service has been started, then its hosting process is
> > > considered to be less important than any processes that are currently
> > > visible to the user on-screen, but more important than any process not
> > > visible."
> > > => it means that the process is ranked as "Service process" level (Cf.
> > > Processes and Threads android doc)
> > > As far as i understand, this priority level should warrant us the
> > > process will only be killed in a very
> > > constraining RAM configuration, and makes it suitable for long time
> > > running background thread..
> > > Is my understanding correct?
> >
> > Please do not have a "long time running background thread" except in
> > extreme situations (e.g., VOIP client), and even then you will need to
> > use startForeground() to keep the service around.
> >
> > Pure background services (i.e., those without an accompanying activity
> > in the foreground) are designed to run for seconds or minutes, not
> > hours or days.
> >
> > > So what the point of launching a background thread in a bound
> > > Service?? What's the difference between a simple thread launching from
> > > an Activity?
> >
> > Activities undergo configuration changes, where they get destroyed and
> > recreated (e.g., screen rotation). Services do not. Dealing with
> > either background threads or bound services is annoying to deal with
> > in an Activity.
> >
> > --
> > Mark Murphy (a Commons Guy)http://commonsware.com|
> http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy
> >
> > Android App Developer Books:http://commonsware.com/books
>
> --
> 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
>



-- 
Dianne Hackborn
Android framework engineer
[email protected]

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