@Override
  public void onConnectionSuspended(int i) {
    Log.d(TAG, "LocationServices connection suspended");

    state = State.SUSPENDED;
    cancelGeofencesFetching();

    if (geofenceRequestIntent != null && geofenceList != null) {
      LocationServices.GeofencingApi.removeGeofences(apiClient, geofenceRequestIntent);
    }
  }
 @Override
 public void onDestroy() {
   super.onDestroy();
   if (mGoogleApiClient.isConnected()) {
     LocationServices.GeofencingApi.removeGeofences(mGoogleApiClient, getGeofencePendingIntent())
         .setResultCallback(this);
     mGoogleApiClient.disconnect();
   }
   if (!Storage.isEmptyLocations()) {
     sendGeofenceInfo();
   }
 }
 /**
  * Removes geofences, which stops further notifications when the device enters or exits previously
  * registered geofences.
  */
 public void removeGeofencesButtonHandler(View view) {
   if (!mGoogleApiClient.isConnected()) {
     Toast.makeText(this, getString(R.string.not_connected), Toast.LENGTH_SHORT).show();
     return;
   }
   try {
     // Remove geofences.
     LocationServices.GeofencingApi.removeGeofences(
             mGoogleApiClient,
             // This is the same pending intent that was used in addGeofences().
             getGeofencePendingIntent())
         .setResultCallback(this); // Result processed in onResult().
   } catch (SecurityException securityException) {
     // Catch exception generated if the app does not use ACCESS_FINE_LOCATION permission.
     logSecurityException(securityException);
   }
 }
 @Override
 public void onConnectionSuspended(int i) {
   if (geofenceRequestIntent != null)
     LocationServices.GeofencingApi.removeGeofences(mGoogleApiClient, geofenceRequestIntent);
   onGeofencePreparedListener.onError(null, "onConnectionSuspended");
 }
Exemple #5
0
 @Override
 public void onConnectionSuspended(int i) {
   if (mGeofencePendingIntent != null) {
     LocationServices.GeofencingApi.removeGeofences(mGoogleApiClient, mGeofencePendingIntent);
   }
 }