- Forum posts: 1
Mar 26, 2019, 10:23:15 PM via Website
Mar 26, 2019 10:23:15 PM via Website
I want to Implement a location listener in my app which will run in the background, even when the app is closed. I found a lot of result for implementing the location listener but is still confused.
My use-case is to get the location in all possible ways, whether it be GPS, Network provider or any other way. The app needs to update location periodically in the background
I found example similar to below to get the precise location:
LocationManager lm = getSystemService(Context.LOCATION_SERVICE);
LocationListener ll = new mylocationlistener();
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, ll);
this doesn't work very accurate, the listener didn't work in background service.
so is this the best way to get the location in the background. Most of the posts I found seem OLD, do we have a better way to implement background location listener in newer API's.
I searched StackOverflow for the same but didn't found a relevant post, if there a post which answers the same, please share the link. Or let me know whats the best way to implement it.
Thanks in advance
Recommended editorial content
With your consent, external content is loaded here.
By clicking on the button above, you agree that external content may be displayed to you. Personal data may be transmitted to third-party providers in the process. You can find more information about this in our Privacy Policy.