Quicknav Quicknav
Links

- Google Play Developer Console
- Android Developers Blog
- About Android

Android Sites

- Android.com
- Android Developers
- Android Open Source Project

close

- - Get Started
  - Style
  - Patterns
  - Building Blocks
  - Downloads
  - Videos
- - Training
  - API Guides
  - Reference
  - Tools
    - Get the SDK
  - Google Services
- - Google Play
  - Publishing
  - Promoting
  - App Quality
  - Spotlight
  - Open Distribution

## Results

Loading...
public interface

# Geofence

com.google.android.gms.location.Geofence

## Class Overview

Represents a geographical region, also known as a geofence. Geofences can be monitored by geofencer service. And when the user crosses the boundary of a geofence, an alert will be generated.

## Summary

Nested Classes
class | Geofence.Builder | A builder that builds `Geofence`.

Constants
int | GEOFENCE_TRANSITION_DWELL | The transition type indicating that the user enters and dwells in geofences for a given period of time.
int | GEOFENCE_TRANSITION_ENTER | The transition type indicating that the user enters the geofence(s).
int | GEOFENCE_TRANSITION_EXIT | The transition type indicating that the user exits the geofence(s).
long | NEVER_EXPIRE | Expiration value that indicates the geofence should never expire.

Public Methods
abstract String | getRequestId() Returns the request ID of this geofence.

## Constants

#### public static final int GEOFENCE_TRANSITION_DWELL

The transition type indicating that the user enters and dwells in geofences for a given period of time. This alert always follows the `GEOFENCE_TRANSITION_ENTER` alert. But an app can always specify this transition type without specifying `GEOFENCE_TRANSITION_ENTER`.

You must set the duration of loitering before this alert is sent using `setLoiteringDelay(int)`.

Constant Value: 4 (0x00000004)

#### public static final int GEOFENCE_TRANSITION_ENTER

The transition type indicating that the user enters the geofence(s).

Constant Value: 1 (0x00000001)

#### public static final int GEOFENCE_TRANSITION_EXIT

The transition type indicating that the user exits the geofence(s).

Constant Value: 2 (0x00000002)

#### public static final long NEVER_EXPIRE

Expiration value that indicates the geofence should never expire.

Constant Value: -1 (0xffffffffffffffff)

## Public Methods

#### public abstract String getRequestId ()

Returns the request ID of this geofence. The request ID is a string to identify this geofence inside your application. When two geofences with the same requestId are monitored, the new one will replace the old one regardless the geographical region these two geofences represent.