在我构建地理围栏的方法中,我在ExpirationDuration(NEVER_EXPIRE)setTransitionTypes(GEOFENCE_TRANSITION_ENTER)上得到一个错误,指出它们不能解析为变量。为什么会这样?
我的方法:

private void buildGeofence(){
    LatLng geofencePoint = marker.getPosition();
    int radius = 1610;
    Geofence.Builder geofence = new Geofence.Builder();
    geofence.setCircularRegion(geofencePoint.latitude,geofencePoint.longitude, radius);
    geofence.setExpirationDuration(NEVER_EXPIRE);
    geofence.setTransitionTypes(GEOFENCE_TRANSITION_ENTER);
    geofence.setNotificationResponsiveness(0);
    geofence.build();
}

最佳答案

这些常量已经在您引用的geofeen类中声明,因此jut将它们用作geofence.setTransitionTypes(Geofence.GEOFENCE_TRANSITION_ENTER);

09-17 22:41