Use the 'startService' method as well. Just bind your activity to your service as you did before, but in addition, call 'startService' to start your service. When your activity exits and unbinds from your service, your service remains alive because it was called by a 'startService'. When you call 'stopService', only then the service will be stopped and destroyed:
http://developer.android.com/reference/android/content/Context.html Look for the startService and stopService methods for more detail. On Aug 25, 2:13 pm, Shany <[email protected]> wrote: > anyone got an idea? > > On Aug 23, 11:28 am, Shany <[email protected]> wrote: > > > > > Hey guys, > > I was wondering on this for quite a bit but couldn't find any > > solution! > > > 1. My app bind to a service (through AIDL interface) > > 2, The service runs in the backround and send to my activity a value > > every now and than (and also a notification is sent) > > > When I click the HOME button, and than navigate back to my application > > (while still i get notifications) to my app and launch it, everything > > is fine, i'm back to my app as if I never left it (i get a window with > > my value displayed) > > > When I click the BACK button the service dies along with the activity > > that is bound to it (the onDestroy() of the service is fired and the > > code there removes all the messages) > > > now, I removed the code that disabled the message handler to my > > services, and the service is kept a live even if i killed the host > > activity. > > > however, the service still runs in the bk and i get notifications but > > when I run my activity again, it wants to start a new service! which > > means, the service in the background is left to run without any > > binding to it, and it just there in the void running. > > > my question: > > How mp3 alike apps in android catch the BACK button and still able to > > keep connection to a service even after the activity is closed? > > > i can save the process ID of the service, but is it possible to attach > > your self to the service? or even re-bind to the existing one? > > > how does it work?? > > thanx!- Hide quoted text - > > - Show quoted text - --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

