Quickstart

VERSION 1.1.0

The Location module provides an interface for obtaining and working with location updates. It provides implementations for getting an actual user location with and without Google Services, 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.

  • AndroidLocationProvider – relies on the Android system location services, which does not require Google services.
    implementation("com.tomtom.sdk.location:provider-android:1.1.0")
  • GmsLocationProvider – based on the Google service’s location updates.
    implementation("com.tomtom.sdk.location:provider-gms:1.1.0")
  • ProxyLocationProvider - publishes locations that are programmatically provided .
    implementation("com.tomtom.sdk.location:provider-proxy:1.1.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.1.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: