// defined origin and radius. A Geofence can also be defined
// as a polygon. The specified GeofenceListener will be notified
// when the BlackBerry device enters or exits the perimeter of the
// geofenced region.
final Geofence geofence = new Geofence();
final Coordinates coordinates =
new Coordinates(ORIGIN_LATITUDE, ORIGIN_LONGITUDE,
Float.NaN);
geofence.monitorPerimeter(this, "RIM Campus", coordinates,
GEOFENCE_RADIUS, 0, -1);
// Add a field to display status
final StringBuffer strBuffer =
new StringBuffer("Geofence enabled for latitude ");
strBuffer.append(coordinates.getLatitude());
strBuffer.append(" and longitude ");
strBuffer.append(coordinates.getLongitude());
strBuffer.append(" with ");
strBuffer.append(GEOFENCE_RADIUS);
strBuffer.append(" meter radius");
_geofenceInfoField = new LabelField(strBuffer.toString());
add(_geofenceInfoField);