Android 更新地理围栏
Android Update Geofences
在 Android 中更新地理围栏的最佳方式是什么?是不是先去掉旧的Geofences集,然后像这样添加新更新的列表:
LocationServices.GeofencingApi.removeGeofences(
mGoogleApiClient,
getGeofencePendingIntent()
).setResultCallback(this);
LocationServices.GeofencingApi.addGeofences(
mGoogleApiClient,
getGeofencingRequest(),
getGeofencePendingIntent()
).setResultCallback(this); // Result processed in onResult().
或者我可以直接调用 addGeofences
而不删除旧的,让新的替换旧的吗?
如果您先阅读手册,您会注意到 addGeofences 说:
If an existing geofence with the same request ID is already registered, the old geofence is replaced by the new one, and the new PendingIntent is used to generate intents for alerts.
在 Android 中更新地理围栏的最佳方式是什么?是不是先去掉旧的Geofences集,然后像这样添加新更新的列表:
LocationServices.GeofencingApi.removeGeofences(
mGoogleApiClient,
getGeofencePendingIntent()
).setResultCallback(this);
LocationServices.GeofencingApi.addGeofences(
mGoogleApiClient,
getGeofencingRequest(),
getGeofencePendingIntent()
).setResultCallback(this); // Result processed in onResult().
或者我可以直接调用 addGeofences
而不删除旧的,让新的替换旧的吗?
如果您先阅读手册,您会注意到 addGeofences 说:
If an existing geofence with the same request ID is already registered, the old geofence is replaced by the new one, and the new PendingIntent is used to generate intents for alerts.