I am writing an app that needs to get gps location information in the background. I created a class derived from Service to do this. I copied the example on the Android developer site about making a background service. It uses the ServiceHandler thread to do the work.
I use location manager and set up the receiving of updates.
I have my main activity create the service using the normal way like this:
Intent intent = new Intent(_context, MyService.class);
Inside my service I create the location manager and start getting location updates.
This works great so far. I am doing this as a service because I want my service to receive updates even if my application is shut down. I test this by holding down the home button and killing my app.
The problem is that as soon as I kill my app the service stops getting updates. The service does not go away, as far as I can tell, it just quits receiving GPS updates.
As long as I leave the app running, even in the background, the service keeps getting the GPS updates.
Can someone tell me how to continue to get GPS updates in my service even if the app that started it gets killed?
I have some settings in my AndroidManifest.xml that might be affecting it. I have the service set up so it is not exported and has permissions. I do this because I don't want other applications to use my service. Could these be affecting it?
Here is my service entry in the xml:
<service android:name="com.mycompany.mypackage.MyService" android:permission="com.mycompany.MY_SERVICE" android:exported="false" />
Just after that outside of the application tag I have this:
<permission android:name="com.mycompany. MY_SERVICE"/>
<uses-permission android:name="com.mycompany. MY_SERVICE" />
Groups "Android Developers" group.
You received this message because you are subscribed to the Google Groups "Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to