Open Moh09 opened 5 years ago
-public class Geofencing implements ResultCallback {
+public class Geofencing implements OnSuccessListener, OnFailureListener {
+ private GeofencingClient geofencingClient;
//onCreate()
+ geofencingClient = LocationServices.getGeofencingClient(mContext);
//registerAllGeofences()
- LocationServices.GeofencingApi.addGeofences(
- mGoogleApiClient,
- getGeofencingRequest(),
- getGeofencePendingIntent()
- ).setResultCallback(this);
+ geofencingClient.addGeofences(getGeofencingRequest(), getGeofencePendingIntent())
+ .addOnSuccessListener(this)
+ .addOnFailureListener(this);
//unRegisterAllGeofences()
- LocationServices.GeofencingApi.removeGeofences(
- mGoogleApiClient,
+ geofencingClient.removeGeofences(
- ).setResultCallback(this);
+ ).addOnSuccessListener(this)
+ .addOnFailureListener(this)
+ ;
- public void updateGeofencesList(PlaceBuffer places) {
+ public void updateGeofencesList(List<Place> places) {
- if (places == null || places.getCount() == 0) return;
+ if (places == null || places.size() == 0) return;
- public void onResult(@NonNull Result result) {
- Log.e(TAG, String.format("Error adding/removing geofence : %s",
- result.getStatus().toString()));
+ public void onFailure(@NonNull Exception e) {
+ Log.d(TAG, "onFailure: Geofence add failure");
+ @Override
+ public void onSuccess(Object o) {
+ Log.d(TAG, "onSuccess: Geofence adeed");
+ }
It have been replace by "GeofencingClient" but how do you integrate that in the code ?
Become ?