public class GeoFenceClient
extends java.lang.Object
| 限定符和类型 | 字段和说明 |
|---|---|
static int |
GEOFENCE_IN
触发围栏行为-进入围栏
Trigger Fence Behavior - Enter Fence |
static int |
GEOFENCE_OUT
触发围栏行为-离开围栏
Trigger Fence Behavior - Exit Fence |
static int |
GEOFENCE_STAYED
触发围栏行为-停留在围栏内(在围栏内停留10分钟以上)
Trigger Fence Behavior - Stay in Fence (Stay in fence for more than 10 minutes) |
| 构造器和说明 |
|---|
GeoFenceClient(android.content.Context context) |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
addGeoFence(DPoint point,
float radius,
java.lang.String customId)
创建自定义围栏
圆形围栏
Create Custom Fence Circular Fence |
void |
addGeoFence(java.util.List<DPoint> points,
java.lang.String customId)
创建自定义围栏
多边形围栏
Create Custom Fence Polygon Fence |
void |
addGeoFence(java.lang.String keyword,
java.lang.String customId)
创建行政区划围栏
Create administrative division geofence |
void |
addGeoFence(java.lang.String keyword,
java.lang.String poiType,
DPoint point,
float aroundRadius,
int size,
java.lang.String customId)
创建高德POI地理围栏
根据周边创建围栏
注意:通过此方法创建的围栏半径全部为200米,暂时不支持自定位围栏半径 Create Amap POI GeoFence Create Fence Based on Surroundings Note: The fence radius created by this method is all 200 meters, and self-positioning fence radius is not supported for now. |
void |
addGeoFence(java.lang.String keyword,
java.lang.String poiType,
java.lang.String city,
int size,
java.lang.String customId)
创建高德POI地理围栏
根据关键字创建围栏
注意:通过此方法创建的围栏半径全部为1000米,暂时不支持自定义围栏半径 Create Amap POI Geofence Create geofence based on keywords Note: The radius of all geofences created by this method is 1000 meters, and custom geofence radius is not currently supported |
android.app.PendingIntent |
createPendingIntent(java.lang.String action)
创建PendingIntent
注意:一个GeoFenceClient只接受一个PendingIntent,如果重复设置多个,则以最后一个为准
Create PendingIntent Note: A GeoFenceClient only accepts one PendingIntent. |
java.util.List<GeoFence> |
getAllGeoFence()
获取所有已经创建的地理围栏
Get all created geofences |
boolean |
isPause()
地理围栏是否已经暂停
Whether the geofence has been paused |
void |
pauseGeoFence()
暂停地理围栏
暂停地理围栏的监听、同时地理围栏内部的定位也会停止
Pause geofence Pause geofence monitoring, and the internal positioning of the geofence will also stop |
void |
removeGeoFence()
移除所有地理围栏
Remove all geofences |
boolean |
removeGeoFence(GeoFence geoFence)
移除指定的geofence
当要移除所有围栏时可以使用
removeGeoFence()方法 当要销毁GeoFneceClient时,需要调用一次
removeGeoFence()方法,确保所有围栏已移除
Remove specified geofence When removing all geofences, you can use the removeGeoFence() method. |
void |
resumeGeoFence()
恢复地理围栏
恢复地理围栏的监听、同时地理围栏内部的定位也会重新开始定位
注意:通过setGeoFenceAble接口设置为false的围栏不会重新生效 Resume geofence Resume geofence monitoring, and the internal positioning of the geofence will also restart Note: Geofences set to false via the setGeoFenceAble interface will not be reactivated |
void |
setActivateAction(int action)
设置触发地理围栏的条件
注意:重复设置不同的触发行为会重复触发围栏
Set Conditions for Triggering GeoFence Note: Repeating different trigger behaviors will repeatedly trigger the fence. |
void |
setGeoFenceAble(java.lang.String fenceId,
boolean able)
设置围栏是否生效,
Set whether the geofence is active, |
void |
setGeoFenceListener(GeoFenceListener geoFenceListener)
设置地理围栏的回调接口
Set GeoFence Callback Interface |
void |
setLocationClientOption(AMapLocationClientOption option) |
public static final int GEOFENCE_IN
public static final int GEOFENCE_OUT
public static final int GEOFENCE_STAYED
public GeoFenceClient(android.content.Context context)
context - public android.app.PendingIntent createPendingIntent(java.lang.String action)
注意:一个GeoFenceClient只接受一个PendingIntent,如果重复设置多个,则以最后一个为准
Note: A GeoFenceClient only accepts one PendingIntent. If multiple are set, the last one will be used.
action - PendingIntent的过滤条件
public void setActivateAction(int action)
注意:重复设置不同的触发行为会重复触发围栏
Note: Repeating different trigger behaviors will repeatedly trigger the fence.
action - 触发围栏的条件
目前支持的条件有:
GEOFENCE_IN 进入GEOFENCE_OUT 离开GEOFENCE_STAYED 停留Currently supported conditions are:
GEOFENCE_IN EnterGEOFENCE_OUT ExitGEOFENCE_STAYED Staypublic void setGeoFenceListener(GeoFenceListener geoFenceListener)
geoFenceListener - public void setLocationClientOption(AMapLocationClientOption option)
public void addGeoFence(DPoint point, float radius, java.lang.String customId)
圆形围栏
Circular Fence
point - 围栏中心点坐标, 必填项
radius - 围栏半径, 必填项
customId - 自定义的围栏标识, 选填,建议必填并且保证唯一性
public void addGeoFence(java.util.List<DPoint> points, java.lang.String customId)
多边形围栏
Polygon Fence
points - 多边形的边界点, 必须大于2个点, 必填项
customId - 自定义的围栏标识, 选填,建议必填并且保证唯一性
public void addGeoFence(java.lang.String keyword,
java.lang.String poiType,
DPoint point,
float aroundRadius,
int size,
java.lang.String customId)
根据周边创建围栏
注意:通过此方法创建的围栏半径全部为200米,暂时不支持自定位围栏半径
Create Fence Based on Surroundings
Note: The fence radius created by this method is all 200 meters, and self-positioning fence radius is not supported for now.
keyword - 关键字, 例如:肯德基, 必填项
poiType - poi类型,例如:餐饮, 选填项
point - 中心点坐标, 必填项
aroundRadius - 周边半径,取值范围[1-50000]
size - 最多创建的围栏数目, 最大25个
customId - 自定义的围栏标识, 选填,建议必填并且保证唯一性
public void addGeoFence(java.lang.String keyword,
java.lang.String poiType,
java.lang.String city,
int size,
java.lang.String customId)
根据关键字创建围栏
注意:通过此方法创建的围栏半径全部为1000米,暂时不支持自定义围栏半径
Create geofence based on keywords
Note: The radius of all geofences created by this method is 1000 meters, and custom geofence radius is not currently supported
keyword - POI关键字, 例如:首开广场, 必填项(keyword和poiType必须至少填一项)
poiType - POI类型,例如:写字楼, 必填项(keyword和poiType必须至少填一项)
city - POI所在的城市名称, 例如:北京, 选填
size - 最大创建的围栏数目,取值范围[1-25]
customId - 自定义的围栏标识, 选填,建议必填并且保证唯一性
public void addGeoFence(java.lang.String keyword,
java.lang.String customId)
keyword - 关键字 必填项
customId - 自定义的围栏标识, 选填,建议必填并且保证唯一性
public void removeGeoFence()
public boolean removeGeoFence(GeoFence geoFence)
当要移除所有围栏时可以使用removeGeoFence()方法 当要销毁GeoFneceClient时,需要调用一次
removeGeoFence()方法,确保所有围栏已移除
When removing all geofences, you can use the removeGeoFence() method. When destroying the GeoFenceClient, you need to call the removeGeoFence() method once to ensure all geofences are removed
geoFence - 要移除的geofence
public java.util.List<GeoFence> getAllGeoFence()
public void setGeoFenceAble(java.lang.String fenceId,
boolean able)
fenceId - 需要改变的地理围栏的fenceId
able - 是否生效,true:生效;false:不生效, 默认:true
public void pauseGeoFence()
暂停地理围栏的监听、同时地理围栏内部的定位也会停止
Pause geofence monitoring, and the internal positioning of the geofence will also stop
public void resumeGeoFence()
恢复地理围栏的监听、同时地理围栏内部的定位也会重新开始定位
注意:通过setGeoFenceAble接口设置为false的围栏不会重新生效
Resume geofence monitoring, and the internal positioning of the geofence will also restart
Note: Geofences set to false via the setGeoFenceAble interface will not be reactivated
public boolean isPause()