Quickstart
The Location module provides an interface for obtaining and working with location updates. It provides implementations for getting an actual user location, as well as one for simulating locations.
To use the Location module, you need to configure the project and add the dependencies.
Project setup
Configure the project as described in the Project setup guide.
Add the module dependency in the build.gradle.kts
of your application module and synchronize the project.
Dependencies
The Location module provides different location provider implementations. To use each one you need to add its dependency in the module’s build.gradle.kts
.
- Default LocationProvider – relies on the Android system location services and does not require Google services.
implementation("com.tomtom.sdk.location:provider-default:1.20.0")
- MapMatchedLocationProvider – provides map-matched locations generated by navigation.
implementation("com.tomtom.sdk.location:provider-map-matched:1.20.0")
- SimulationLocationProvider – simulates location updates using the provided list of locations.
implementation("com.tomtom.sdk.location:provider-simulation:1.20.0")
- LocationProvider - an interface to implement with a custom location provider. It is included in all of the dependencies listed above.
implementation("com.tomtom.sdk.location:provider-api:1.20.0")
Location permissions
If the application is going to use user location data, you have to request the correct permissions. In particular, the user must grant location permission before the location provider can be used. Complete instructions to request location permissions on Android can be found here.
Battery saver mode
Some devices don’t allow location updates in the foreground because of the default "battery saver" mode being enabled. Therefore, you need to manually confirm the battery saver status and change it to "No restrictions" mode in app settings. Once these changes are made, the foreground service begins to receive location updates.
Next steps
Since you have learned how to use basic location functionality, here are recommendations for the next steps: