Nic Hubbard
Nic Hubbard

Reputation: 42139

Android Google Play Location Services continue after leaving app

I am using Google Play Services in my app so that I can make use of the Location features. I have read the docs, but it isn't clear what happens when I am running location updates and I leave the app.

Do location updates still occur in the background? If not, how do I do this?

Upvotes: 0

Views: 458

Answers (2)

wakaka
wakaka

Reputation: 553

Do location updates still occur in the background? If not, how do I do this?

What I did for my app was to continue to track the location with a service in the background. In addition, you may want to start and mark the service as Foreground so that user will be shown a notification that you are tracking the phone's location.

Upvotes: 2

user2652394
user2652394

Reputation: 1686

Make sure you remove the LocationListener when you leave your app, usually I put it in onPause() method of the Activity, otherwise, it's up to you to handle whether you should do it. Here is the example code:

@Override   
protected void onPause() {      
locationMananger.removeUpdates(this);       
// with "this" is your Activity implementing the LocationListener       
super.onPause();    
}

Hope this helps.

Upvotes: 0

Related Questions