Android Update Geofences

Tom*_*ond 3 android geofencing android-geofence

在Android中更新地理围栏的最佳方法是什么?是先删除旧的Geofences集合,然后像这样添加新更新的列表:

            LocationServices.GeofencingApi.removeGeofences(
                    mGoogleApiClient,
                    getGeofencePendingIntent()
            ).setResultCallback(this);

            LocationServices.GeofencingApi.addGeofences(
                    mGoogleApiClient,
                    getGeofencingRequest(),
                    getGeofencePendingIntent()
            ).setResultCallback(this); // Result processed in onResult().
Run Code Online (Sandbox Code Playgroud)

或者我可以直接打电话addGeofences而不删除旧的,并让新的替换旧的?

Mar*_*och 6

如果您首先阅读本手册,您会注意到addGeofences说:

如果已注册具有相同请求ID的现有地理围栏,则旧地理围栏将替换为新地理围栏,并且新的PendingIntent将用于生成警报的意图.