Aracılığıyla paylaş


MapLocationProvider Class (Android only)

Note

Bing Maps SDK for Android and iOS retirement

Bing Maps SDK for Android and iOS is deprecated and will be retired. Free (Basic) account customers can continue to use Bing Maps SDK for Android and iOS until June 30th, 2025. Enterprise account customers can continue to use Bing Maps SDK for Android and iOS until June 30th, 2028. To avoid service disruptions, all implementations using Bing Maps SDK for Android and iOS will need to be updated to use Azure Maps Web SDK by the retirement date that applies to your Bing Maps for Enterprise account type.

Azure Maps is Microsoft's next-generation maps and geospatial services for developers. Azure Maps has many of the same features as Bing Maps for Enterprise, and more. To get started with Azure Maps, create a free Azure subscription and an Azure Maps account. For more information about azure Maps, see Azure Maps Documentation. For migration guidance, see Bing Maps Migration Overview.

An abstract class that contains common methods for all Android location providers.

abstract class MapLocationProvider implements SensorEventListener

See GPSMapLocationProvider for a concrete class you can use.

See MapUserLocation for more details on how to start tracking user location with a location provider.

Methods

startTracking

Starts tracking the location on the device. This method may be called multiple times and stopTracking should be called once for each call to startTracking that returns MapUserLocationTrackingState.READY.

MapUserLocationTrackingState startTracking()

stopTracking

Stops a previous call to start tracking. Must be called once for each call to startTracking that returns MapUserLocationTrackingState.READY.

void stopTracking()

Events

LocationChanged

Fired when a location event is received while tracking is active.
removeLocationChangedListener returns false if the listener has not been previously added or has been already removed.
See LocationChangedListener for more details on the listener interface.

void addLocationChangedListener(LocationChangedListener locationChangedListener)
boolean removeLocationChangedListener(LocationChangedListener locationChangedListener)

Properties

LastLocation

Returns the last location emitted by this location provider, if any. Returns android.location.Location.

@Nullable android.location.Location getLastLocation()

SensorSamplingPeriod

Represents sensor sampling period in microseconds for retrieving heading. Note that this value is only a hint to the system and events may be received faster or slower than the specified rate. Usually, events are received faster than the specified rate. This value can not be less than 0. Default sensorSamplingPeriod is SensorManager.SENSOR_DELAY_NORMAL.

If set is called before location retrieval started, setting will be saved for when location retrieval starts. If set is called after location retrieval started, it will restart with the new setting.

void setSensorSamplingPeriod(int sensorSamplingPeriod)
int getSensorSamplingPeriod()