Try running it in a different process:
android:processThe name of the process where the service is to run. 
Normally, all components of an application run in the default process 
created for the application. It has the same name as the application 
package. The <application> 
<http://developer.android.com/guide/topics/manifest/application-element.html>
 element's process 
<http://developer.android.com/guide/topics/manifest/application-element.html#proc>
 attribute 
can set a different default for all components. But component can override 
the default with its own process attribute, allowing you to spread your 
application across multiple processes.

If the name assigned to this attribute begins with a colon (':'), a new 
process, private to the application, is created when it's needed and the 
service runs in that process. If the process name begins with a lowercase 
character, the service will run in a global process of that name, provided 
that it has permission to do so. This allows components in different 
applications to share a process, reducing resource usage.

Nir

On Sunday, November 23, 2014 8:44:45 AM UTC+2, Tony Pitman wrote:
>
> 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);
> _context.startService(intent);
>
> 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" />
>
>
>

-- 
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
--- 
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 android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to