Aracılığıyla paylaş


LocationManager Class

Definition

This class provides access to the system location services.

[Android.Runtime.Register("android/location/LocationManager", DoNotGenerateAcw=true)]
public class LocationManager : Java.Lang.Object
[<Android.Runtime.Register("android/location/LocationManager", DoNotGenerateAcw=true)>]
type LocationManager = class
    inherit Object
Inheritance
LocationManager
Attributes

Remarks

This class provides access to the system location services. These services allow applications to obtain periodic updates of the device's geographical location, or to be notified when the device enters the proximity of a given geographical location.

<p class="note">Unless otherwise noted, all Location API methods require the android.Manifest.permission#ACCESS_COARSE_LOCATION or android.Manifest.permission#ACCESS_FINE_LOCATION permissions. If your application only has the coarse permission then providers will still return location results, but the exact location will be obfuscated to a coarse level of accuracy.

Java documentation for android.location.LocationManager.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Constructors

LocationManager(IntPtr, JniHandleOwnership)

A constructor used when creating managed representations of JNI objects; called by the runtime.

Fields

ActionGnssCapabilitiesChanged

Broadcast intent action when GNSS capabilities change.

ExtraGnssCapabilities

Intent extra included with #ACTION_GNSS_CAPABILITIES_CHANGED broadcasts, containing the new GnssCapabilities.

ExtraLocationEnabled

Intent extra included with #MODE_CHANGED_ACTION broadcasts, containing the boolean enabled state of location.

ExtraProviderEnabled

Intent extra included with #PROVIDERS_CHANGED_ACTION broadcasts, containing the boolean enabled state of the location provider that has changed.

ExtraProviderName

Intent extra included with #PROVIDERS_CHANGED_ACTION broadcasts, containing the name of the location provider that has changed.

FusedProvider

Standard name of the fused location provider.

GpsProvider

Standard name of the GNSS location provider.

KeyFlushComplete

Key used for an extra holding an integer request code when location flush completion is sent using a PendingIntent.

KeyLocationChanged

Key used for an extra holding a Location value when a location change is sent using a PendingIntent.

KeyLocations

Key used for an extra holding a array of Locations when a location change is sent using a PendingIntent.

KeyProviderEnabled

Key used for an extra holding a boolean enabled/disabled status value when a provider enabled/disabled event is broadcast using a PendingIntent.

KeyProximityEntering

Key used for the Bundle extra holding a boolean indicating whether a proximity alert is entering (true) or exiting (false).

KeyStatusChanged

This key is no longer in use.

ModeChangedAction

Broadcast intent action when the device location enabled state changes.

NetworkProvider

Standard name of the network location provider.

PassiveProvider

A special location provider for receiving locations without actively initiating a location fix.

ProvidersChangedAction

Broadcast intent action when the set of enabled location providers changes.

Properties

AllProviders

Returns a list of the names of all available location providers.

Class

Returns the runtime class of this Object.

(Inherited from Object)
GnssAntennaInfos

Returns the current list of GNSS antenna infos, or null if unknown or unsupported.

GnssCapabilities

Returns the supported capabilities of the GNSS chipset.

GnssHardwareModelName

Returns the model name (including vendor and hardware/software version) of the GNSS hardware driver, or null if this information is not available.

GnssYearOfHardware

Returns the model year of the GNSS hardware and software build, or 0 if the model year is before 2016.

Handle

The handle to the underlying Android instance.

(Inherited from Object)
IsLocationEnabled

Returns the current enabled/disabled state of location.

JniIdentityHashCode (Inherited from Object)
JniPeerMembers
PeerReference (Inherited from Object)
ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Methods

AddGpsStatusListener(GpsStatus+IListener)

Adds a GPS status listener.

AddNmeaListener(GpsStatus+INmeaListener)

No-op method to keep backward-compatibility.

AddNmeaListener(IExecutor, IOnNmeaMessageListener)

Adds an NMEA listener.

AddNmeaListener(IOnNmeaMessageListener, Handler)

Adds an NMEA listener.

AddNmeaListener(IOnNmeaMessageListener)

Adds an NMEA listener.

AddProximityAlert(Double, Double, Single, Int64, PendingIntent)

Sets a proximity alert for the location given by the position (latitude, longitude) and the given radius.

AddTestProvider(String, Boolean, Boolean, Boolean, Boolean, Boolean, Boolean, Boolean, Power, SensorStatus)

Creates a test location provider and adds it to the set of active providers.

AddTestProvider(String, ProviderProperties, ICollection<String>)

Creates a test location provider and adds it to the set of active providers.

AddTestProvider(String, ProviderProperties)

Creates a test location provider and adds it to the set of active providers.

ClearTestProviderEnabled(String)

Equivalent to calling #setTestProviderEnabled(String, boolean) to disable a test provider.

ClearTestProviderLocation(String)

Does nothing.

ClearTestProviderStatus(String)

This method has no effect as provider status has been deprecated and is no longer supported.

Clone()

Creates and returns a copy of this object.

(Inherited from Object)
Dispose() (Inherited from Object)
Dispose(Boolean) (Inherited from Object)
Equals(Object)

Indicates whether some other object is "equal to" this one.

(Inherited from Object)
FromContext(Context)
GetBestProvider(Criteria, Boolean)

Returns the name of the provider that best meets the given criteria.

GetCurrentLocation(String, CancellationSignal, IExecutor, IConsumer)

Asynchronously returns a single current location fix from the given provider.

GetCurrentLocation(String, LocationRequest, CancellationSignal, IExecutor, IConsumer)

Asynchronously returns a single current location fix from the given provider based on the given LocationRequest.

GetGpsStatus(GpsStatus)

Retrieves information about the current status of the GPS engine.

GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
GetLastKnownLocation(String)

Gets the last known location from the given provider, or null if there is no last known location.

GetProvider(String)

Returns the information about the location provider with the given name, or null if no provider exists by that name.

GetProviderProperties(String)

Returns the properties of the given provider, or null if the properties are currently unknown.

GetProviders(Boolean)

Returns a list of the names of available location providers.

GetProviders(Criteria, Boolean)

Returns a list of the names of available location providers that satisfy the given criteria.

HasProvider(String)

Returns true if the given location provider exists on this device, irrespective of whether it is currently enabled or not.

IsProviderEnabled(String)

Returns the current enabled/disabled status of the given provider.

JavaFinalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
RegisterAntennaInfoListener(IExecutor, GnssAntennaInfo+IListener)

Registers a GNSS antenna info listener that will receive all changes to antenna info.

RegisterGnssMeasurementsCallback(GnssMeasurementRequest, IExecutor, GnssMeasurementsEvent+Callback)

Registers a GNSS measurements callback which will run on a binder thread.

RegisterGnssMeasurementsCallback(GnssMeasurementsEvent+Callback, Handler)

Registers a GNSS measurements callback which will run on a binder thread.

RegisterGnssMeasurementsCallback(GnssMeasurementsEvent+Callback)

Registers a GNSS measurements callback which will run on a binder thread.

RegisterGnssMeasurementsCallback(IExecutor, GnssMeasurementsEvent+Callback)

Registers a GNSS measurements callback which will run on a binder thread.

RegisterGnssNavigationMessageCallback(GnssNavigationMessage+Callback, Handler)

Registers a GNSS navigation message callback which will run on a binder thread.

RegisterGnssNavigationMessageCallback(GnssNavigationMessage+Callback)

Registers a GNSS navigation message callback which will run on a binder thread.

RegisterGnssNavigationMessageCallback(IExecutor, GnssNavigationMessage+Callback)

Registers a GNSS navigation message callback which will run on a binder thread.

RegisterGnssStatusCallback(GnssStatus+Callback, Handler)

Registers a GNSS status callback.

RegisterGnssStatusCallback(GnssStatus+Callback)

Registers a GNSS status callback.

RegisterGnssStatusCallback(IExecutor, GnssStatus+Callback)

Registers a GNSS status callback.

RemoveGpsStatusListener(GpsStatus+IListener)

Removes a GPS status listener.

RemoveNmeaListener(GpsStatus+INmeaListener)

No-op method to keep backward-compatibility.

RemoveNmeaListener(IOnNmeaMessageListener)

Removes an NMEA listener.

RemoveProximityAlert(PendingIntent)

Removes the proximity alert with the given PendingIntent.

RemoveTestProvider(String)

Removes the test location provider with the given name or does nothing if no such test location provider exists.

RemoveUpdates(ILocationListener)

Removes all location updates for the specified LocationListener.

RemoveUpdates(PendingIntent)

Removes location updates for the specified PendingIntent.

RequestFlush(String, ILocationListener, Int32)

Requests that the given provider flush any batched locations to listeners.

RequestFlush(String, PendingIntent, Int32)

Requests that the given provider flush any batched locations to listeners.

RequestLocationUpdates(Int64, Single, Criteria, IExecutor, ILocationListener)

Register for location updates using a provider selected through the given Criteria, and a callback on the specified Executor.

RequestLocationUpdates(Int64, Single, Criteria, ILocationListener, Looper)

Register for location updates using a provider selected through the given Criteria, and a callback on the specified Looper.

RequestLocationUpdates(Int64, Single, Criteria, PendingIntent)

Register for location updates using a provider selected through the given Criteria, and callbacks delivered via the provided PendingIntent.

RequestLocationUpdates(String, Int64, Single, IExecutor, ILocationListener)

Register for location updates using the named provider, and a callback on the specified Executor.

RequestLocationUpdates(String, Int64, Single, ILocationListener, Looper)

Register for location updates from the given provider with the given arguments, and a callback on the specified Looper.

RequestLocationUpdates(String, Int64, Single, ILocationListener)

Register for location updates from the given provider with the given arguments, and a callback on the Looper of the calling thread.

RequestLocationUpdates(String, Int64, Single, PendingIntent)

Register for location updates using the named provider, and callbacks delivered via the provided PendingIntent.

RequestLocationUpdates(String, LocationRequest, IExecutor, ILocationListener)

Register for location updates from the specified provider, using a LocationRequest, and a callback on the specified Executor.

RequestLocationUpdates(String, LocationRequest, PendingIntent)

Register for location updates from the specified provider, using a LocationRequest, and callbacks delivered via the provided PendingIntent.

RequestSingleUpdate(Criteria, ILocationListener, Looper)

Register for a single location update using a Criteria and a callback.

RequestSingleUpdate(Criteria, PendingIntent)

Register for a single location update using a Criteria and pending intent.

RequestSingleUpdate(String, ILocationListener, Looper)

Register for a single location update using the named provider and a callback.

RequestSingleUpdate(String, PendingIntent)

Register for a single location update using a named provider and pending intent.

SendExtraCommand(String, String, Bundle)

Sends additional commands to a location provider.

SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
SetTestProviderEnabled(String, Boolean)

Sets the given test provider to be enabled or disabled.

SetTestProviderLocation(String, Location)

Sets a new location for the given test provider.

SetTestProviderStatus(String, Availability, Bundle, Int64)

This method has no effect as provider status has been deprecated and is no longer supported.

ToArray<T>() (Inherited from Object)
ToString()

Returns a string representation of the object.

(Inherited from Object)
UnregisterAntennaInfoListener(GnssAntennaInfo+IListener)

Unregisters a GNSS antenna info listener.

UnregisterFromRuntime() (Inherited from Object)
UnregisterGnssMeasurementsCallback(GnssMeasurementsEvent+Callback)

Unregisters a GPS Measurement callback.

UnregisterGnssNavigationMessageCallback(GnssNavigationMessage+Callback)

Unregisters a GNSS Navigation Message callback.

UnregisterGnssStatusCallback(GnssStatus+Callback)

Removes a GNSS status callback.

Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)

Explicit Interface Implementations

IJavaPeerable.Disposed() (Inherited from Object)
IJavaPeerable.DisposeUnlessReferenced() (Inherited from Object)
IJavaPeerable.Finalized() (Inherited from Object)
IJavaPeerable.JniManagedPeerState (Inherited from Object)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from Object)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from Object)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)

Applies to