【发布时间】:2015-12-14 09:20:04
【问题描述】:
我正在构建一个包含谷歌地理围栏的应用程序,我使用 ENTER 和 EXIT 转换创建了该应用程序。
当打开“Location”时会出现问题,当在我的地理围栏内时,它会触发两个转换,而只有 ENTER 转换应该触发。
我将 ENTER 和 EXIT 都设置为 intitialTrigger()。
这怎么可能?
这是 google api 的错误还是我在构建器中做错了什么。提前致谢。
@Override
public void onResult(Result result) {
Status s = result.getStatus();
Log.d(TAG, "onResult(...)" + s.isSuccess());
if (!s.isSuccess()) {
Log.d(TAG, "statuskode = " + s.getStatusCode() +
" noget gik galt, sandsynlighvis blev gps slået fra = statuscode 1000");
}
}
private GeofencingRequest createGeoFences() {
return new GeofencingRequest.Builder()
.addGeofence(geoFenceBuilder(Constants.LOCATION_BALLERUP, "ballerup_req_id"))
.addGeofence(geoFenceBuilder(Constants.LOCATION_AALBORG, "aalborg_req_id"))
.addGeofence(geoFenceBuilder(Constants.LOCATION_ESBJERG, "esbjerg_req_id"))
.addGeofence(geoFenceBuilder(Constants.LOCATION_ÅRHUS, "århus_req_id"))
// .addGeofence(geoFenceBuilder(Constants.LOCATION_TAASTRUP, 44))
.setInitialTrigger(GeofencingRequest.INITIAL_TRIGGER_ENTER | GeofencingRequest.INITIAL_TRIGGER_EXIT)
.build();
}
private Geofence geoFenceBuilder(LatLng location, String requestId) {
return new Geofence.Builder().setCircularRegion(location.latitude, location.longitude, TARGET_RADIUS)
.setExpirationDuration(Geofence.NEVER_EXPIRE)
.setTransitionTypes(Geofence.GEOFENCE_TRANSITION_ENTER | Geofence.GEOFENCE_TRANSITION_EXIT)
.setRequestId(requestId)
.setNotificationResponsiveness(NOTIFICATION_DELAY)
.build();
}
【问题讨论】:
标签: android geofencing