private void synchronizeAllFencesToGoogleApi(){
  Log.i(TAG,"Try to update list of fences");
  if (mGapiFenceManager.isConnected()) {
    ArrayList<StorableFence> toAddFences=mToAddStore.getAllFences();
    if (!toAddFences.isEmpty()) {
      for (      StorableFence storableFence : toAddFences) {
        FenceAddStatus addStatus=new FenceAddStatus(storableFence);
        if ((storableFence.getId() != null) && (storableFence.getPendingIntentClass() != null)) {
          mGapiFenceManager.addFence(storableFence.getId(),storableFence.getAwarenessFence(mContext),storableFence.getPendingIntentClass(),addStatus);
        }
        Log.i(TAG,"Added " + storableFence);
      }
      Log.i(TAG,"All fences to add have been submitted to be synchronized with Google API Client");
    }
    Set<String> toRemoveFences=mToRemoveStore.getAllFenceIds();
    if (!toRemoveFences.isEmpty()) {
      for (      String fenceId : toRemoveFences) {
        FenceRemoveStatus removeStatus=new FenceRemoveStatus(fenceId);
        mGapiFenceManager.removeFence(fenceId,removeStatus);
        Log.i(TAG,"Removed " + fenceId);
      }
      Log.i(TAG,"All fences to remove have been submitted to be synchronized with Google API Client");
    }
  }
 else {
    mGapiFenceManager.connect();
  }
}

private void synchronizeAllFencesToGoogleApi ( ) { Log . i ( TAG , "Try to update list of fences" ) ; if ( mGapiFenceManager . isConnected ( ) ) { ArrayList < StorableFence > toAddFences = mToAddStore . getAllFences ( ) ; if ( ! toAddFences . isEmpty ( ) ) { for ( StorableFence storableFence : toAddFences ) { FenceAddStatus addStatus = new FenceAddStatus ( storableFence ) ; if ( ( storableFence . getId ( ) != null ) && ( storableFence . getPendingIntentClass ( ) != null ) ) { mGapiFenceManager . addFence ( storableFence . getId ( ) , storableFence . getAwarenessFence ( mContext ) , storableFence . getPendingIntentClass ( ) , addStatus ) ; } Log . i ( TAG , "Added " + storableFence ) ; } Log . i ( TAG , "All fences to add have been submitted to be synchronized with Google API Client" ) ; } Set < String > toRemoveFences = mToRemoveStore . getAllFenceIds ( ) ; if ( ! toRemoveFences . isEmpty ( ) ) { for ( String fenceId : toRemoveFences ) { FenceRemoveStatus removeStatus = new FenceRemoveStatus ( fenceId ) ; mGapiFenceManager . removeFence ( fenceId , removeStatus ) ; Log . i ( TAG , "Removed " + fenceId ) ; } Log . i ( TAG , "All fences to remove have been submitted to be synchronized with Google API Client" ) ; } } else { mGapiFenceManager . connect ( ) ; } }
ask to synchronize all stored fences to the google api client
