Interface LocationManager

com.yandex.mapkit.location

public interface LocationManager

All Known Subinterfaces:
DummyLocationManager, LocationSimulator

Handles location updates and changes.

Methods

void requestSingleUpdate(@NonNull LocationListener locationListener)

Subscribe to a single location update.

void resume()

Resumes updates stopped by a suspend() call.

void subscribeForLocationUpdates(double desiredAccuracy, long minTime, double minDistance, boolean allowUseInBackground, @NonNull FilteringMode filteringMode, @NonNull LocationListener locationListener)

Subscribe for location update events.

void suspend()

Stops updates for all subscriptions until resume() is called.

void unsubscribe(@NonNull LocationListener locationListener)

Unsubscribe from location update events.

Method Detail

requestSingleUpdate

public void requestSingleUpdate (@NonNull LocationListener locationListener)

Subscribe to a single location update.

If the listener was already subscribed to location updates, the previous subscription will be removed.
Parameters:
locationListener

Location update listener.

resume

public void resume ()

Resumes updates stopped by a suspend() call.

subscribeForLocationUpdates

public void subscribeForLocationUpdates (double desiredAccuracy, long minTime, double minDistance, boolean allowUseInBackground, @NonNull FilteringMode filteringMode, @NonNull LocationListener locationListener)

Subscribe for location update events.

If the listener was already subscribed to updates from the LocationManager, subscription settings will be updated. Use desiredAccuracy = 0 to obtain best possible accuracy, minTime = 0 to ignore minTime and use minDistance instead, minDistance = 0 to use only minTime. If both minTime and minDistance are set to zero, the subscription will use the same settings as other LocationManager clients.
Parameters:
desiredAccuracy

Desired location accuracy, in meters. This value is used to configure location services provided by the host OS. If locations with the desired accuracy are not available, updates may be called with lower accuracy.

minTime

Minimal time interval between events, in milliseconds.

minDistance

Minimal distance between location updates, in meters.

allowUseInBackground

Defines whether the subscription can continue to fetch notifications when the application is inactive. If allowUseInBackground is true, set the location flag in UIBackgroundModes for your application.

filteringMode

Defines whether locations should be filtered.

locationListener

Location update listener.

suspend

public void suspend ()

Stops updates for all subscriptions until resume() is called.

unsubscribe

public void unsubscribe (@NonNull LocationListener locationListener)

Unsubscribe from location update events.

Can be called for either subscribeForLocationUpdates() or requestSingleUpdate(). For requestSingleUpdate()- if an event was already received- unsubscribe() does not have any effect. If the listener is already unsubscribed, the method call is ignored.
Parameters:
locationListener

Listener passed to either subscribeForLocationUpdates() or requestSingleUpdate().