예제 #1
0
 /*
  * Called by Location Services if the attempt to
  * Location Services fails.
  */
 @Override
 public void onConnectionFailed(ConnectionResult connectionResult) {
   /*
    * Google Play services can resolve some errors it detects.
    * If the error has a resolution, try sending an Intent to
    * start a Google Play services activity that can resolve
    * error.
    */
   if (connectionResult.hasResolution()) {
     try {
       // Start an Activity that tries to resolve the error
       connectionResult.startResolutionForResult(this, CONNECTION_FAILURE_RESOLUTION_REQUEST);
       /*
        * Thrown if Google Play services canceled the original
        * PendingIntent
        */
     } catch (IntentSender.SendIntentException e) {
       // Log the error
       e.printStackTrace();
     }
   } else {
     /*
      * If no resolution is available, display a dialog to the
      * user with the error.
      */
     //    showErrorDialog(connectionResult.getErrorCode());
   }
 }
 /*
  * Called by Location Services if the attempt to Location Services fails.
  */
 @Override
 public void onConnectionFailed(ConnectionResult connectionResult) {
   /*
    * Google Play services can resolve some errors it detects. If the error
    * has a resolution, try sending an Intent to start a Google Play
    * services activity that can resolve error.
    */
   if (connectionResult.hasResolution()) {
     try {
       // Start an Activity that tries to resolve the error
       connectionResult.startResolutionForResult(this, CONNECTION_FAILURE_RESOLUTION_REQUEST);
       /*
        * Thrown if Google Play services canceled the original
        * PendingIntent
        */
     } catch (IntentSender.SendIntentException e) {
       // Log the error
       e.printStackTrace();
     }
   } else {
     Toast.makeText(
             getApplicationContext(),
             "Sorry. Location services not available to you",
             Toast.LENGTH_LONG)
         .show();
   }
 }
예제 #3
0
 @Override
 public void onConnectionFailed(ConnectionResult connectionResult) {
   if (statusesToHandle.contains(connectionResult.getErrorCode())) {
     GooglePlayServicesUtil.getErrorDialog(connectionResult.getErrorCode(), this, 0).show();
   }
   if (!gPlusSignInInProgress) {
     if (gPlusSignInClicked && connectionResult.hasResolution()) {
       try {
         gPlusSignInInProgress = true;
         startIntentSenderForResult(
             connectionResult.getResolution().getIntentSender(), 0, null, 0, 0, 0);
       } catch (IntentSender.SendIntentException e) {
         e.printStackTrace();
         gPlusSignInInProgress = false;
         googleApiClient.connect();
       }
     } else {
       googleApiClient.disconnect();
       if (progressDialog != null) {
         progressDialog.dismiss();
       }
     }
   } else {
     googleApiClient.disconnect();
     if (progressDialog != null) {
       progressDialog.dismiss();
     }
   }
 }
  // GooglePlayServicesClient.OnConnectionFailedListener
  @Override
  public void onConnectionFailed(ConnectionResult connectionResult) {
    /*
     * Google Play services can resolve some errors it detects.
     * If the error has a resolution, try sending an Intent to
     * start a Google Play services activity that can resolve
     * error.
     */
    if (connectionResult.hasResolution()) {
      try {
        // start an activity that tries to resolve that error
        connectionResult.startResolutionForResult(
            this, LocationUtils.CONNETION_FAILURE_RESOLUTION_REQUEST);

        /*
         * Thrown if Google Play services canceled the original
         * PendingIntent
         */
      } catch (IntentSender.SendIntentException ex) {
        ex.printStackTrace();
      }
    } else {
      showErrorDialog(connectionResult.getErrorCode());
    }
  }
예제 #5
0
 @Override
 public void onConnectionFailed(ConnectionResult connectionResult) {
   if (connectionResult.hasResolution()) {
     try {
       connectionResult.startResolutionForResult(
           (Activity) context, CONNECTION_FAILURE_RESOLUTION_REQUEST);
     } catch (IntentSender.SendIntentException e) {
       e.printStackTrace();
     }
   }
 }
예제 #6
0
 @Override
 public void onConnectionFailed(ConnectionResult connectionResult) {
   if (connectionResult.hasResolution()) {
     try {
       // Start an Activity that tries to resolve the error
       connectionResult.startResolutionForResult(this, CONNECTION_FAILURE_RESOLUTION_REQUEST);
     } catch (IntentSender.SendIntentException e) {
       e.printStackTrace();
     }
   } else {
     Log.i(
         TAG, "Location services connection failed with code " + connectionResult.getErrorCode());
   }
 }
 @Override
 public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
   if (connectionResult.hasResolution() && mContext instanceof Activity) {
     try {
       Activity activity = (Activity) mContext;
       connectionResult.startResolutionForResult(activity, CONNECTION_FAILURE_RESOLUTION_REQUEST);
     } catch (IntentSender.SendIntentException e) {
       Log.e(TAG, e.getMessage());
     }
   } else {
     Log.i(
         TAG, "Location services connection failed with code: " + connectionResult.getErrorCode());
     connectUsingOldApi();
   }
 }
  @Override
  public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
    Log.d(TAG, "Location services failed connecting. Please try again.");

    if (connectionResult.hasResolution()) {
      try {
        connectionResult.startResolutionForResult(this, CONNECTION_FAILURE_RESOLUTION_REQUEST);
      } catch (IntentSender.SendIntentException e) {
        e.printStackTrace();
      }
    } else {
      Log.i(
          TAG, "Location services connection failed with code " + connectionResult.getErrorCode());
    }
  }
예제 #9
0
    @Override
    protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);

      Intent intent = getIntent();

      ConnectionResult connectionResult = intent.getParcelableExtra("connectionResult");
      int id = intent.getIntExtra("idOfStartResolutionListener", -1);
      listener = GPlusManager.getInstance().onStartResolutionListeners.get(id);
      GPlusManager.getInstance().onStartResolutionListeners.remove(id);

      try {
        connectionResult.startResolutionForResult(this, 0);
      } catch (IntentSender.SendIntentException e) {
        e.printStackTrace();
      }
    }
 /**
  * This method receives the connection error details and tries to execute the error resolution
  * provided by the object itself.
  *
  * <p>The error resolution opens a Dialog that informs the user what to do to resolve the issue.
  * Then the operation result is received on onActivityResult
  */
 private void handleConnectionFailureError(Parcelable errorDetails) {
   // TODO: change errorDetails to avoid the usage of the instanceof operator. Bad smells.
   if (errorDetails != null) {
     if (errorDetails instanceof ConnectionResult) {
       ConnectionResult result = (ConnectionResult) errorDetails;
       try {
         result.startResolutionForResult(this, REQUEST_RESOLVE_GOOGLE_SERVICES_ERROR);
         isResolvingError = true;
       } catch (IntentSender.SendIntentException e) {
         e.printStackTrace();
         postEventAndFinish(new OnStrategyErrorNotSolved());
       }
     } else if (errorDetails instanceof Status) {
       Status status = (Status) errorDetails;
       try {
         status.startResolutionForResult(this, REQUEST_RESOLVE_GOOGLE_SERVICES_ERROR);
         isResolvingError = true;
       } catch (IntentSender.SendIntentException e) {
         e.printStackTrace();
         postEventAndFinish(new OnStrategyErrorNotSolved());
       }
     }
   }
 }
예제 #11
0
  // Called when the connection to Google Play Services fails.
  @Override
  public void onConnectionFailed(ConnectionResult connectionResult) {
    Activity activity = getActivity("onConnectionFailed()");
    if (activity == null) {
      return;
    }

    if (connectionResult.hasResolution()) {
      if (sCanShowSignInUi) {
        LOGD(TAG, "onConnectionFailed, with resolution. Attempting to resolve.");
        sCanShowSignInUi = false;
        try {
          mResolving = true;
          connectionResult.startResolutionForResult(
              activity, REQUEST_RECOVER_FROM_PLAY_SERVICES_ERROR);
        } catch (IntentSender.SendIntentException e) {
          LOGE(TAG, "SendIntentException occurred: " + e.getMessage());
          e.printStackTrace();
        }
      } else {
        LOGD(TAG, "onConnectionFailed with resolution but sCanShowSignInUi==false.");
        reportAuthFailure();
      }
      return;
    }

    LOGD(TAG, "onConnectionFailed, no resolution.");
    final int errorCode = connectionResult.getErrorCode();
    if (GooglePlayServicesUtil.isUserRecoverableError(errorCode) && sCanShowSignInUi) {
      sCanShowSignInUi = false;
      GooglePlayServicesUtil.getErrorDialog(errorCode, activity, REQUEST_PLAY_SERVICES_ERROR_DIALOG)
          .show();
    } else {
      reportAuthFailure();
    }
  }