0

Я добавил геозоны в API Google Geofence, как в that example. времени от времени я хотел бы, чтобы стереть эти геозоны (либо по одному или всем togehter), независимо от их срока действия и т.д.Как стереть все геофенсионы, загруженные в API Google Geofence?

mGeofenceList.add(new Geofence.Builder() 
    // Set the request ID of the geofence. This is a string to identify this 
    // geofence. 
    .setRequestId(entry.getKey()) 

    .setCircularRegion(
      entry.getValue().latitude, 
      entry.getValue().longitude, 
      Constants.GEOFENCE_RADIUS_IN_METERS 
    ) 
    .setExpirationDuration(Constants.GEOFENCE_EXPIRATION_IN_MILLISECONDS) 
    .setTransitionTypes(Geofence.GEOFENCE_TRANSITION_ENTER | 
      Geofence.GEOFENCE_TRANSITION_EXIT) 
    .build()); 

Как стереть эти геозоны подаваемых в API Google Геозонов самого ?

ответ

0

Позвоните removeGeofences(GoogleApiClient client, PedingIntent pendingIntent), чтобы удалить все геозоны, связанные с данным pendingIntent.

Использование FLAG_UPDATE_CURRENT, а не FLAG_CANCEL_CURRENT при создании ожидающего намерения, иначе вы не получите то же отложенное намерение Вы предоставили addGeofences (GoogleApiClient, List, PendingIntent) https://developers.google.com/android/reference/com/google/android/gms/location/GeofencingApi.html#addGeofences(com.google.android.gms.common.api.GoogleApiClient, com.google.android.gms.location.GeofencingRequest, андроид .app.PendingIntent)], и поэтому операция удаления ничего не удалит.