/**
  * Handle the user's action from the permissioning workflow. In this workflow a user may be asked
  * for access to his profile, email, offline access etc.
  *
  * <p>There are three situations we cover:
  *
  * <p>1. The user clicks sign in. We are not yet connected to the google services api. (common
  * case)
  *
  * <p>2. The user clicks sign in and we are already connected to the google services api. This
  * case is less common, and it's a bit confusing why we'd already be connected to the google
  * services api before the user clicks sign in. This case happens when the user sees multiple
  * pages in the permission workflow. The user will see multiple pages in the workflow when we
  * connect to the google services api (successfully), but on connection google tells us that we
  * should prompt the user for even more permissions that the first page of the workflow didn't ask
  * for via a UserRecoverableAuthException. For example, a user may first be prompted for basic
  * profile access. Then when we connect to the google services api it may suggest that we also
  * need to prompt the user for offline access. In this case we don't bother reconnecting to the
  * google services api again. Instead, we skip straight to resolving to the token.
  *
  * <p>3. The user clicks cancel.
  *
  * @param requestCode The request code originally supplied to startActivityForResult(),
  * @param resultCode The integer result code returned by the child activity through its
  *     setResult().
  * @param intent Information returned by the child activity
  */
 @Override
 public void onActivityResult(int requestCode, final int resultCode, final Intent intent) {
   super.onActivityResult(requestCode, resultCode, intent);
   if (mGoogleApiClient == null) {
     buildGoogleApiClient();
   }
   if (!mGoogleApiClient.isConnected() && resultCode == Activity.RESULT_OK) {
     mGoogleApiClient.connect();
   } else if (resultCode == Activity.RESULT_OK) {
     this.resolveToken(email, result);
   } else {
     this.savedCallbackContext.error("user cancelled");
   }
 }
 public void onActivityResult(int requestCode, int resultCode, Intent intent) {
   Log.v(TAG, "onActivityResult: " + requestCode + " " + resultCode);
   super.onActivityResult(requestCode, resultCode, intent);
   if (ACTIVITY_CODE_PLAY_MEDIA == requestCode) {
     if (Activity.RESULT_OK == resultCode) {
       this.callbackContext.success();
     } else if (Activity.RESULT_CANCELED == resultCode) {
       String errMsg = "Error";
       if (intent != null && intent.hasExtra("message")) {
         errMsg = intent.getStringExtra("message");
       }
       this.callbackContext.error(errMsg);
     }
   }
 }