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

2011-03-05 Thread pedro242
Still no anwsers/comments..

Not any specialist of Android Services?...

On Mar 1, 8:06 pm, pedro242 pedro.contreir...@gmail.com wrote:
 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


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

2011-03-05 Thread pedro242
(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 mmur...@commonsware.com wrote:
 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/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 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


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

2011-03-05 Thread Mark Murphy
On Sat, Mar 5, 2011 at 11:30 AM, pedro242 pedro.contreir...@gmail.com wrote:
 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??

If your activity is no longer in the foreground (e.g., user presses
HOME), then it and its service are not considered a high-priority
process.

If your activity is destroyed (e.g., user presses BACK, Android
destroys the background activity to free up RAM), then your service
will be destroyed, because you should have unbound from the service
when your activity is destroyed. Please do not attempt to bind to
services then leak them by never unbinding them.

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


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

2011-03-05 Thread Dianne Hackborn
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 pedro.contreir...@gmail.comwrote:

 (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 mmur...@commonsware.com wrote:
  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/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 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




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

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

2011-03-05 Thread pedro242
Thanks Dianne for your answer..

I just compared the basic thread and a thread launched in a service
process
upon an AIDL request in the sense that if the client actvity was
destroyed, then
in both cases, the basic long time running thread and the service
thread would
also be destroyed...

With your responses it's now more clear for me.. and by the way I
realized
it's make no sense in launching a thread upon an AIDL request from a
component and expecting this thread keeps on running, after the
component
be destroyed.

(Dianne, your Multitasking the Android Way paper is very very
helpfull, keep
on doing things in this way..)

On Mar 5, 7:04 pm, Dianne Hackborn hack...@android.com wrote:
 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 pedro.contreir...@gmail.comwrote:



  (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 mmur...@commonsware.com wrote:
   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/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 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

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

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

2011-03-05 Thread Kostya Vasilyev
Service.startForeground does increase the chances that the service will keep
running (as this puts the service into foreground process class).

You can use this independently of binding, it's orthogonal that way.

Can be useful if the user requests some kind of update from the network (for
example) and you'd like to be able to finish it even if the user leaves the
controlling activity before it's done.
06.03.2011 2:09 пользователь pedro242 pedro.contreir...@gmail.com
написал:
 Thanks Dianne for your answer..

 I just compared the basic thread and a thread launched in a service
 process
 upon an AIDL request in the sense that if the client actvity was
 destroyed, then
 in both cases, the basic long time running thread and the service
 thread would
 also be destroyed...

 With your responses it's now more clear for me.. and by the way I
 realized
 it's make no sense in launching a thread upon an AIDL request from a
 component and expecting this thread keeps on running, after the
 component
 be destroyed.

 (Dianne, your Multitasking the Android Way paper is very very
 helpfull, keep
 on doing things in this way..)

 On Mar 5, 7:04 pm, Dianne Hackborn hack...@android.com wrote:
 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 pedro.contreir...@gmail.com
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 mmur...@commonsware.com wrote:
   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/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

[android-developers] Re: Service Process Vs background process

2011-02-17 Thread blcooley
On Feb 17, 7:11 am, Sivaprakash sivaprakashshanmu...@gmail.com
wrote:
 OK if you go through the following link

 http://developer.android.com/guide/topics/fundamentals.html

 Processes and lifecycles sectionthere are two things Service Process and
 Background Process, how they differ each other?

 - Siva


The process descriptions at the bottom of that link are letting you
know the order in which the OS will reclaim resources.

Here's my rudimentary understanding:

background process is something that is not currently visible or
actively processing, the canonical example being an Activity whose
onStop() has been called. Such processes can be killed by the OS when
it needs to reclaim resources.

service process is something that is not visible, but is currently
processing and affecting the user experience. Think of playing music
or monitoring location, for example.

A Service (i.e. instantiation of the class Service) can and will be
classified as all of those processes during its lifetime. Part of the
confusion is that a service isn't necessarily running in a separate
process from the Activity that instantiates it and launches it.

-- 
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] Re: (Service == Process)?

2008-12-02 Thread patrick

Hi guys,

thanks very much for your answers. Your answers and the link that I
obviously missed helped me clear out these things.

Patrick

On Dec 1, 8:03 pm, Dianne Hackborn [EMAIL PROTECTED] wrote:
 On Mon, Dec 1, 2008 at 5:41 AM, patrick [EMAIL PROTECTED] wrote:
   - therefore an activity is a process
    - but from what I know a service uses another address space than the
  hosting activity

 If there is anything 
 inhttp://code.google.com/android/intro/appmodel.htmlorthe other docs
 leading you to this conclusion, please let me know what
 that is so we can fix it. :)

  - how are AIDL IPC calls synchronized when they are different
  processes?

 There is a special driver in the kernel called binder that takes care of
 these IPCs.

 --
 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.  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
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: (Service == Process)?

2008-12-01 Thread Mark Murphy

patrick wrote:
 I am a little confused about the difference between services and
 processes in Android. From what I understood:
  - each package may run as one process

At minimum. A package might have more than one process, though that is 
discouraged.

  - therefore an activity is a process

No, because a package may have more than one activity.

  - a service runs in the main thread of an activity (therefore it
 needs to run in the same process)

If it is a local service, yes. Or, in your AndroidManifest.xml file, you 
could specify that the service is to run in another process.

  - but from what I know a service uses another address space than the
 hosting activity

A local service shares the address space with anything else in that 
process, including, possibly, one or more activities.

  - because I don't know of another way in Linux to create a new
 virtual memory space than by using a new process I assume, that a
 service is actually a new process

Only if you set it up that way in AndroidManifest.xml. And, again, this 
is discouraged.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com

Android Training on the Ranch! -- Mar 16-20, 2009
http://www.bignerdranch.com/schedule.shtml

--~--~-~--~~~---~--~~
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
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: (Service == Process)?

2008-12-01 Thread Dianne Hackborn
On Mon, Dec 1, 2008 at 5:41 AM, patrick [EMAIL PROTECTED] wrote:

  - therefore an activity is a process
   - but from what I know a service uses another address space than the
 hosting activity


If there is anything in
http://code.google.com/android/intro/appmodel.htmlor the other docs
leading you to this conclusion, please let me know what
that is so we can fix it. :)


 - how are AIDL IPC calls synchronized when they are different
 processes?


There is a special driver in the kernel called binder that takes care of
these IPCs.

-- 
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.  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
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---