views:

94

answers:

1

I have a series of 3 activities, and the 3rd activity binds (I'm using AIDL) to a Service. What I notice is, if I am on the 3rd activity and start the service, on clicking the back button (moving from 3rd activity to 2nd activity), the Service onDestroy() gets called, and the Service is stopped.

How can I ensure that the service runs even if the Activity is closed?

This is how I bind to the service in the 3rd activity's onCreate method:

this.bindService(new Intent(this,MyService.class), mConnection, Context.BIND_AUTO_CREATE);

Thanks Chris

A: 

Use Context#startService. The service will continue to run until stopService is called or the device kills it to free up memory or is killed by the user.

Qberticus