Re: [android-developers] service process priority: startService() vs bindService()

2011-03-05 Thread Mark Murphy
On Tue, Mar 1, 2011 at 2:06 PM, pedro242 pedro.contreir...@gmail.com 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/commonsguy
http://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 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


[android-developers] service process priority: startService() vs bindService()

2011-03-02 Thread pedro242
Hi there,

I would need your help to clarify what is the priority
of a process hosting a Service when the service is
either started (startService() ) or bound (bindService()):

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?

My concern deals with the bound case..
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?? It would then mean that it does
not keep ranked as Service process level (started case) and will be
about to be destroyed by
the system at any time..
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?

Am i missing a point? Any comments?
Thanks..

Pedro

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