[android-developers] Re: Keeping service alive - What is the right way to to go for my app?

2008-12-11 Thread Jean-Baptiste Queru

You can not rely on a service staying alive 100% of the time, because
the system reserves the right to kill the processes that host services
in order to make space for the visible activity.

JBQ

On Thu, Dec 11, 2008 at 3:21 PM, code_android_festival_way
festival.s...@googlemail.com wrote:

 At the moment I'm facing kind of a big problem. I am using a service
 to listen with the TelephonyManager for incoming calls in order to do
 something according to the incoming call. To be able to do this I have
 to rely on my running service. It is just sitting in the background
 doing nothing. I know that the right behaviour for this situation
 would be a BroadcastReceiver registered in the Manifest. But there is
 no brodcast sent for incoming calls. So I can't walk this way.

 Is there a possibility to keep my service reliable alive? At the
 moment I'm just starting the service from my UI with startService
 (..). Later on I'm binding to my service. Most of the time the
 service is running fine in the background but in some rare situations
 the service gets killed by the system and is kept killed untill I
 restart it from my UI.

 Could someone tell me what to do in this case?

 I'm looking forward reading your answers.

 Regards!
 


--~--~-~--~~~---~--~~
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: Keeping service alive - What is the right way to to go for my app?

2008-12-11 Thread code_android_festival_way

Ok so all I can do is set some last Toast in the onDestroy message in
order to notify the user of the killed service right?

On 12 Dez., 00:29, Jean-Baptiste Queru j...@google.com wrote:
 You can not rely on a service staying alive 100% of the time, because
 the system reserves the right to kill the processes that host services
 in order to make space for the visible activity.

 JBQ

 On Thu, Dec 11, 2008 at 3:21 PM, code_android_festival_way

 festival.s...@googlemail.com wrote:

  At the moment I'm facing kind of a big problem. I am using a service
  to listen with the TelephonyManager for incoming calls in order to do
  something according to the incoming call. To be able to do this I have
  to rely on my running service. It is just sitting in the background
  doing nothing. I know that the right behaviour for this situation
  would be a BroadcastReceiver registered in the Manifest. But there is
  no brodcast sent for incoming calls. So I can't walk this way.

  Is there a possibility to keep my service reliable alive? At the
  moment I'm just starting the service from my UI with startService
  (..). Later on I'm binding to my service. Most of the time the
  service is running fine in the background but in some rare situations
  the service gets killed by the system and is kept killed untill I
  restart it from my UI.

  Could someone tell me what to do in this case?

  I'm looking forward reading your answers.

  Regards!
--~--~-~--~~~---~--~~
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: Keeping service alive - What is the right way to to go for my app?

2008-12-11 Thread Mark Murphy

code_android_festival_way wrote:
 Ok so all I can do is set some last Toast in the onDestroy message in
 order to notify the user of the killed service right?

1. I don't think services can raise Toasts, if they don't happen to be 
called on the UI thread. You should be able to post a 
Notification...though I'm not sure if that will survive the service 
closing down.

2. You can't even be assured onDestroy() is called -- the process might 
just be terminated outright in extreme cases.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com
_The Busy Coder's Guide to Android Development_ Version 1.9 Published!

--~--~-~--~~~---~--~~
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: Keeping service alive - What is the right way to to go for my app?

2008-12-11 Thread Jean-Baptiste Queru

In fact when the system (kernel) decides to kill a service to make
space, the service *is* killed outright, no onDestroy().

JBQ

On Thu, Dec 11, 2008 at 3:44 PM, Mark Murphy mmur...@commonsware.com wrote:

 code_android_festival_way wrote:
 Ok so all I can do is set some last Toast in the onDestroy message in
 order to notify the user of the killed service right?

 1. I don't think services can raise Toasts, if they don't happen to be
 called on the UI thread. You should be able to post a
 Notification...though I'm not sure if that will survive the service
 closing down.

 2. You can't even be assured onDestroy() is called -- the process might
 just be terminated outright in extreme cases.

 --
 Mark Murphy (a Commons Guy)
 http://commonsware.com
 _The Busy Coder's Guide to Android Development_ Version 1.9 Published!

 


--~--~-~--~~~---~--~~
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: Keeping service alive - What is the right way to to go for my app?

2008-12-11 Thread code_android_festival_way

Thank you for your answers. I meant the notification not the Toast
sorry for that. It is not nice to hear all that but ok I have to live
with that. (the users have to live with that because they don't
understand why the service can't be available all the time :) ) It
would be nice if a broadcast would be available for incoming calls
which would make the whole thing a lot easier. (and I wouldn't have to
missuse the service in that way)

Regards!

On 12 Dez., 00:45, Jean-Baptiste Queru j...@google.com wrote:
 In fact when the system (kernel) decides to kill a service to make
 space, the service *is* killed outright, no onDestroy().

 JBQ

 On Thu, Dec 11, 2008 at 3:44 PM, Mark Murphy mmur...@commonsware.com wrote:

  code_android_festival_way wrote:
  Ok so all I can do is set some last Toast in the onDestroy message in
  order to notify the user of the killed service right?

  1. I don't think services can raise Toasts, if they don't happen to be
  called on the UI thread. You should be able to post a
  Notification...though I'm not sure if that will survive the service
  closing down.

  2. You can't even be assured onDestroy() is called -- the process might
  just be terminated outright in extreme cases.

  --
  Mark Murphy (a Commons Guy)
 http://commonsware.com
  _The Busy Coder's Guide to Android Development_ Version 1.9 Published!
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---