Android.Hardware.Location.GeofenceHardware.AddGeofence Method
Creates a circular geofence which is monitored by subsystems in the hardware.

Syntax

[Android.Runtime.Register("addGeofence", "(IILandroid/hardware/location/GeofenceHardwareRequest;Landroid/hardware/location/GeofenceHardwareCallback;)Z", "")]
public bool AddGeofence (int geofenceId, [Android.Runtime.GeneratedEnum] GeofenceMonitoringType monitoringType, GeofenceHardwareRequest geofenceRequest, GeofenceHardwareCallback callback)

Parameters

geofenceId
The id associated with the geofence.
monitoringType
The type of the hardware subsystem that should be used to monitor the geofence.
geofenceRequest
The Android.Hardware.Location.GeofenceHardwareRequest object associated with the geofence.
callback
Android.Hardware.Location.GeofenceHardwareCallback that will be use to notify the transition.

Returns

Documentation for this section has not yet been entered.

Exceptions

TypeReason
Java.Lang.IllegalArgumentExceptionwhen the geofence request type is not supported.

Remarks

Creates a circular geofence which is monitored by subsystems in the hardware.

When the device detects that is has entered, exited or is uncertain about the area specified by the geofence, the given callback will be called.

If this call returns true, it means that the geofence has been sent to the hardware. GeofenceHardwareCallback.OnGeofenceAdd(int, Android.Hardware.Location.GeofenceMonitorStatus) will be called with the result of the add call from the hardware. The GeofenceHardwareCallback.OnGeofenceAdd(int, Android.Hardware.Location.GeofenceMonitorStatus) will be called with the following parameters when a transition event occurs.

The geofence will be monitored by the subsystem specified by monitoring_type parameter. The application does not need to hold a wakelock when the monitoring is being done by the underlying hardware subsystem. If the same geofence Id is being monitored by two different monitoring systems, the same id can be used for both calls, as long as the same callback object is used.

Requires Android.Manifest.Permission.AccessFineLocation permission when GeofenceHardware.MonitoringTypeGpsHardware is used.

Requires Android.Manifest.Permission.LocationHardware permission to access geofencing in hardware.

This API should not be called directly by the app developers. A higher level api which abstracts the hardware should be used instead. All the checks are done by the higher level public API. Any needed locking should be handled by the higher level API.

Create a geofence request object using the methods in Android.Hardware.Location.GeofenceHardwareRequest to set all the characteristics of the geofence. Use the created GeofenceHardwareRequest object in this call.

[Android Documentation]

Requirements

Namespace: Android.Hardware.Location
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 18