Getting Started with the SDK
How to use the Fused Location API
The Fused Location API can be used as follows.
Please check the example code.
Order of API calls
1. Initialize SDK
Call the initialize API to initialize the Fused Location SDK when starting it.
- Kotlin
- Java
val fusedLocation:FusedLocation = FusedLocation(context)
fusedLocation.initialize()
FusedLocation fusedLocation = new FusedLocation(context);
fusedLocation.initialize();
2. Add Listener
Call the registerFusedLocationCallback API to register the FusedLocation callback.
- Kotlin
- Java
val listener = object : FusedLocationListener {
override fun onChanged(location: LocationData?) {
// Handle location updates.
}
override fun onError(exception: Exception) {
// Handle errors.
}
}
fusedLocation.registerFusedLocationCallback(listener)
FusedLocationListener listener = new FusedLocationListener() {
@Override
public void onChanged(LocationData location) {
// Handle location updates.
}
@Override
public void onError(Exception exception) {
// Handle errors.
}
};
fusedLocation.registerFusedLocationCallback(listener);
3. Remove Listener
Before exiting the app, release the previously registered FusedLocation callback. To release the callback, call the unregisterFusedLocationCallback API.
- Kotlin
- Java
fusedLocation.unregisterFusedLocationCallback(listener)
fusedLocation.unregisterFusedLocationCallback(listener);
4. Release SDK
Call the release API to free the resources of the Fused Location SDK.
- Kotlin
- Java
fusedLocation.release()
fusedLocation.release();