androidkotlingeolocationlocationfusedlocationproviderclient

What's the best approach to implement User Location Tracker in Android nowadays


I know and I have read some articles that give us some tutorial about how to do this, but when I want to implement one of the approach they have given, I usually got null or errors with FusedLocationProviderClient It usually happened when I turned off the GPS and turned It back on. And when I opened the Google Maps and back into my app, the FusedLocationProviderClient back to normal and gives actual longitude and latitude. Any idea or help for how can I handle this kind of bug?


Solution

  • Nah nevermind, I solved it by replacing fusedLocation.lastLocation() with fusedLocation.currentLocation(). My bad for following tutorial that uses lastLocation