If i remeber correctly, the 'relevance' of the service is as high as the activity with the highest 'relevance' that is bound to it. With 'relevance' i mean the importance of the activity/service that Android OS uses to determine if it can be killed by the OS or not.
In your case, only *your* activity is bound to it. When your activity is in the foreground, it has the highest 'relevance'. Since it's bound to your service, the service has the highest relevance as well. Android OS will not kill either your activity or your service. When your activity goes to the background (onPause, onStop), your activity gets a lower relevance and maybe considered for killing when necessary. Since it is the only activity still bound to your service, your service's relevance gets lower as well and it may be considered for killing by the OS. This is probably what happens; the OS disconnects and kills your service. When your service is killed but not your activity (which is still paused/stopped), you should get a callback in your bind-request callback-handler of this event (disconnect event). When you activity goes to the foreground again (onResume), your service should be restarted (and your bind-request callback-handler will be notified of this re-connect event as well). On Dec 21, 11:57 am, Kalyan Akella <[email protected]> wrote: > Thank you for the reply. > > I'm indeed returning a valid IBinder inside the service's onBind method. > Here it is: > > public class MyService extends IntentService { > private Messenger myMessenger; > > // Service Constructor > public MyService() { > super("MyService"); > *myMessenger = new Messenger(new MyServiceHandler(this))*; > } > > @Override > public IBinder onBind(Intent intent) { > Log.i(APP_TAG, "Inside service onBind"); > return *myMessenger.getBinder()*; > } > > // other methods... > > } > > Moreover I ensured that my activity calls the *unbindService()* method only > from inside its *onDestroy()* method and no where else. This is exactly > what's been puzzling me as to why android still decides to unbind & kill the > service even if the activity that spawned it is still alive in the first > place. > > Am I missing something here ?? Any pointers ??? > Sincere Regards, > Kalyan -- 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

