Capan
Capan

Reputation: 736

How can I get GPS data even on background on Android?

I have an application that uses both GPS and Network location providers. When I turn on the GPS , I'm recording the locatin data to an arraylist. Then I'm drawing my GPS track with a button. But the problem is when program goes background I can't get any location data. So the lines being drawed dashed.

I'm removing both of the providers under onStop() function. But when I removed that order its just stopping again.

How can I get data even on background ?

Upvotes: 0

Views: 2629

Answers (1)

nickfox
nickfox

Reputation: 2835

I have a full working sample using the Google Play Services fused location (which is what you should be using).

https://github.com/nickfox/GpsTracker/tree/master/phoneClients/android

that is built with Android Studio. And I also have a tutorial that explains how it works here:

https://www.websmithing.com/2014/04/23/how-the-gpstracker-android-client-works/

And finally, to learn more about the new Android location services, read this:

https://developer.android.com/google/play-services/location.html

Upvotes: 1

Related Questions