Showing a map of the user’s location
Having successfully obtained permission from the user to access their location, we can now ask the user’s device to provide us with its last known location. This is also usually the user’s current location. We will then use this location to present the user with a map of their current location.
To obtain the user’s last known location, Google has provided us with the Google Play Location service and, more specifically, with the FusedLocationProviderClient
class. The FusedLocationProviderClient
class helps us interact with Google’s Fused Location Provider API, which is a location API that intelligently combines different signals from multiple device sensors to provide us with device location information.
To access the FusedLocationProviderClient
class, we must first include the Google Play Location service library in our project. This simply means adding the following code snippet to the dependencies
block...