|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.rim.device.api.location.Geofence
public class Geofence
Provides methods that allow you to define geofenced areas and receive notifications when a BlackBerry device user enters or leaves the specified area.
A geofence is a virtual geographic area of interest that you can define by a radius around a location, or by coordinates that define a polygon for the location.
Applications must instantiate a Geofence
object and implement
the GeofenceListener
to receive notifications for geofencing events (when
a user enters or exits geofenced areas). Each instance of Geofence
can process up to 20 monitored areas concurrently.
Field Summary | ||
---|---|---|
static int |
API_ACCESS_DENIED
Indicates denied access to the API. |
|
static int |
DUPLICATE_COORDINATES
Indicates duplicate coordinates. |
|
static int |
DUPLICATE_TAG
Indicates a duplicate tag was specified. |
|
static int |
INVALID_NUMBER_OF_COORDINATES
Indicates an invalid number of coordinates. |
|
static int |
INVALID_PARAMETERS
Indicates the specified parameters are invalid. |
|
static int |
INVALID_TAG
Indicates an invalid tag was specified. |
|
static int |
LOCATION_ACCURACY_HIGH
Indicates the location accuracy level is high. |
|
static int |
LOCATION_ACCURACY_LOW
Indicates the location accuracy level is low. |
|
static int |
LOCATION_ACCURACY_MEDIUM
Indicates the location accuracy level is medium. |
|
static int |
LOCATION_DISALLOWED_BY_IT_POLICY
Indicates location services are disallowed by an IT policy. |
|
static int |
LOCATION_DISALLOWED_BY_USER
Indicates location services are disallowed by the user. |
|
static int |
LOW_BATTERY
Indicates current device battery level is low. |
|
static int |
MAX_NUMBER_OF_MONITORED_AREAS
Indicates the maximum number of areas to monitor. |
|
static int |
NO_ERROR
Indicates no error. |
|
static int |
NUMBER_OF_MONITORED_AREAS_EXCEEDED
Indicates the number of monitored areas is exceeded. |
|
static int |
OTHER_FAILURE
Indicates other possible failure. |
|
static int |
OUT_OF_SERVICE
Indicates current device location is unavailable. |
|
static int |
SUCCESS
Indicates success. |
|
static int |
TEMPORARILY_UNAVAILABLE_AUTO_RESTART
Indicates current device location is temporarily unavailable. |
Constructor Summary | ||
---|---|---|
Geofence()
Constructs a new Geofence instance. |
Method Summary | ||
---|---|---|
boolean |
isInPerimeter(String tag)
Indicates whether the device is on or inside the perimeter of the monitored area. |
|
int |
monitorPerimeter(GeofenceListener listener,
String tag,
Coordinates coordinates,
int radius,
int accuracyFactor,
int duration)
Defines and monitors a circular perimeter for a location of interest during a specified time period. |
|
int |
monitorPerimeter(GeofenceListener listener,
String tag,
Coordinates[] coordinates,
int accuracyFactor,
int duration)
Defines and monitors the perimeter for a polygon area during a specified time period. |
|
int |
removePerimeter(String tag)
Stops monitoring a specified area. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int MAX_NUMBER_OF_MONITORED_AREAS
public static final int SUCCESS
public static final int INVALID_PARAMETERS
public static final int INVALID_NUMBER_OF_COORDINATES
public static final int DUPLICATE_COORDINATES
public static final int INVALID_TAG
public static final int DUPLICATE_TAG
public static final int NUMBER_OF_MONITORED_AREAS_EXCEEDED
public static final int API_ACCESS_DENIED
public static final int OTHER_FAILURE
public static final int LOCATION_ACCURACY_HIGH
public static final int LOCATION_ACCURACY_MEDIUM
public static final int LOCATION_ACCURACY_LOW
public static final int NO_ERROR
public static final int LOCATION_DISALLOWED_BY_IT_POLICY
public static final int LOCATION_DISALLOWED_BY_USER
public static final int TEMPORARILY_UNAVAILABLE_AUTO_RESTART
public static final int OUT_OF_SERVICE
public static final int LOW_BATTERY
Constructor Detail |
---|
public Geofence()
Geofence
instance.
Method Detail |
---|
public int monitorPerimeter(GeofenceListener listener, String tag, Coordinates coordinates, int radius, int accuracyFactor, int duration)
The device is considered to have entered the area
if it was previously outside the perimeter and its current location is
now within the perimeter.
The device is inside the perimeter until it moves a specified distance
(defined by accuracyFactor
) beyond the perimeter.
listener
- A listener that is implemented by the application to
handle geofencing events.tag
- A unique string (for example, "coffee shop") that describes
the perimeter to monitor. The tag is used to stop the monitoring request.coordinates
- The location coordinates (latitude-longitude in decimal
degrees) for the perimeter's center.radius
- The radius (in meters) for the perimeter.accuracyFactor
- The distance (in meters) beyond the perimeter representing
a zone that isn't monitored.duration
- The period of time (in minutes) during which the perimeter
is monitored. When the duration is reached, the perimeter monitoring
is stopped. If you want to re-start monitoring, you must re-add the area.
You can specify -1 to monitor
the area for an indefinite period until the process exits.
public int monitorPerimeter(GeofenceListener listener, String tag, Coordinates[] coordinates, int accuracyFactor, int duration)
The coordinates are the vertices of a
simple concave or convex polygon. The device is considered to
have entered the area if it was previously outside the perimeter
and its current location is now within the perimeter.
The device is inside the area until it moves a specified distance
(defined by accuracyFactor
) beyond the perimeter.
listener
- A listener that is implemented by the application to
handle geofencing events.tag
- A unique string (for example, "coffee shop") that describes
the perimeter to monitor. The tag is used to stop the monitoring request.coordinates
- An ordered set of latitude-longitude values
(in decimal degrees) that define the perimeter of the
polygon area to monitor. There must be a
minimum of 3 and a maximum of 50 unique
coordinates. The first and last coordinates
are automatically joined by an edge to
close off the polygon.accuracyFactor
- The distance (in meters) beyond the perimeter representing
a zone that isn't monitored.duration
- The period of time (in minutes) during which the perimeter
is monitored. When the duration is reached, the perimeter monitoring
is stopped. If you want to re-start monitoring, you must re-add the area.
You can specify -1 to monitor
the area for an indefinite period until the process exits.
public int removePerimeter(String tag)
tag
- The string tag (for example, "coffee shop") that is associated with
the specified area.
public boolean isInPerimeter(String tag) throws ControlledAccessException, LocationException
The current device location is determined from the last known location of the device within the past 30 seconds.
tag
- The string tag (for example, "coffee shop") that is associated with
the specified area.
true
if the device's current location is on or inside the perimeter
of the monitored area, false
otherwise.
ControlledAccessException
- if the calling application does
not have permission to call this method.
LocationException
- if the current location cannot be determined.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright 1999-2011 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Java is a trademark of Oracle America Inc. in the US and other countries.
Legal