Summary: Methods | Inherited Methods | [Expand All]
public final class

# LocationFence

extends Object

java.lang.Object
↳ | com.google.android.gms.awareness.fence.LocationFence

## Class Overview

Use this class to create location-based fences.

Note: Values that indicate a changing state are momentarily `TRUE` for about 5 seconds, then automatically revert to `FALSE`.

## Summary

Public Methods
static AwarenessFence | entering(double latitude, double longitude, double radius) This fence is momentarily (about 5 seconds) in the `TRUE` state when the user enters the specified circle.
static AwarenessFence | exiting(double latitude, double longitude, double radius) This fence is momentarily (about 5 seconds) in the `TRUE` state when the user exits the specified circle.
static AwarenessFence | in(double latitude, double longitude, double radius, long dwellTimeMillis) This fence is in the `TRUE` state when the user's location is within the specified circle, and the user has been in the circle for at least the `dwellTimeMillis` that was specified.

[Expand] Inherited Methods
From class java.lang.Object
Object | clone()
boolean | equals(Object arg0)
void | finalize()
final Class<?> | getClass()
int | hashCode()
final void | notify()
final void | notifyAll()
String | toString()
final void | wait(long arg0, int arg1)
final void | wait(long arg0)
final void | wait()

## Public Methods

#### public static AwarenessFence entering (double latitude, double longitude, double radius)

This fence is momentarily (about 5 seconds) in the `TRUE` state when the user enters the specified circle.

To use this method, your app must declare the `android.permission.ACCESS_FINE_LOCATION` permission in AndroidManifest.xml, and the user must provide consent at runtime.

##### Parameters

latitude | Center latitude of the circle in degrees, between -90 and +90 inclusive.
longitude | Center longitude of the circle in degrees, between -180 and +180 inclusive.
radius | Radius defining the circular region, in meters.

##### Returns

- the `AwarenessFence` object representing this fence.

#### public static AwarenessFence exiting (double latitude, double longitude, double radius)

This fence is momentarily (about 5 seconds) in the `TRUE` state when the user exits the specified circle.

Your app must declare the `android.permission.ACCESS_FINE_LOCATION` permission in your AndroidManifest and be granted this permission to use this API.

##### Parameters

latitude | center latitude of the circle in degrees, between -90 and +90 inclusive
longitude | center longitude of the circle in degrees, between -180 and +180 inclusive
radius | radius in meters defining the circular region.

##### Returns

- the `AwarenessFence` object representing this fence.

#### public static AwarenessFence in (double latitude, double longitude, double radius, long dwellTimeMillis)

This fence is in the `TRUE` state when the user's location is within the specified circle, and the user has been in the circle for at least the `dwellTimeMillis` that was specified.

To use this method, your app must declare the `android.permission.ACCESS_FINE_LOCATION` permission in AndroidManifest.xml, and the user must provide consent at runtime.

##### Parameters

latitude | Center latitude of the circle in degrees, between -90 and +90 inclusive.
longitude | Center longitude of the circle in degrees, between -180 and +180 inclusive.
radius | Radius defining the circular region, in meters.
dwellTimeMillis | Minimum dwelling time inside a location before the fence is in the `TRUE` state. Must be a value greater than or equal to 0L.

##### Returns

- the `AwarenessFence` object representing this fence.