Exemplo n.º 1
0
  @Override
  public void onStart() {
    super.onStart();

    OptionalPendingResult<GoogleSignInResult> opr =
        Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
    if (opr.isDone()) {

      Log.d(TAG, "Got cached sign-in"); /*
            GoogleSignInResult result = opr.get();
            handleSignInResult(result);*/

      Intent dashbIntent = new Intent(this, ProfileActivity.class);
      dashbIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
      startActivity(dashbIntent);

    } else {
      // If the user has not previously signed in on this device or the sign-in has expired,
      // this asynchronous branch will attempt to sign in the user silently.  Cross-device
      // single sign-on will occur in this branch.
      //            showProgressDialog();
      /*opr.setResultCallback(new ResultCallback<GoogleSignInResult>() {
                      @Override
                      public void onResult(GoogleSignInResult googleSignInResult) {
      //                    hideProgressDialog();
                          handleSignInResult(googleSignInResult);
                      }
                  });*/
    }
  }
  @Override
  public void onStart() {
    super.onStart();

    OptionalPendingResult<GoogleSignInResult> opr =
        Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
    if (opr.isDone()) {
      // If the user's cached credentials are valid, the OptionalPendingResult will be "done"
      // and the GoogleSignInResult will be available instantly.
      Log.d(TAG, "Got cached sign-in");
      GoogleSignInResult result = opr.get();
      handleSignInResult(result);
    } else {
      // If the user has not previously signed in on this device or the sign-in has expired,
      // this asynchronous branch will attempt to sign in the user silently.  Cross-device
      // single sign-on will occur in this branch.
      showProgressDialog();
      opr.setResultCallback(
          new ResultCallback<GoogleSignInResult>() {
            @Override
            public void onResult(GoogleSignInResult googleSignInResult) {
              hideProgressDialog();
              handleSignInResult(googleSignInResult);
            }
          });
    }
  }
Exemplo n.º 3
0
 @Override
 public void onResume() {
   super.onResume();
   OptionalPendingResult<GoogleSignInResult> opr =
       Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
   if (opr.isDone()) {
     GoogleSignInResult result = opr.get();
     handleSignInResult(result);
     showShortenBox(true);
     showSignInButton(false);
   } else {
     opr.setResultCallback(
         new ResultCallback<GoogleSignInResult>() {
           @Override
           public void onResult(GoogleSignInResult googleSignInResult) {
             showSignInButton(true);
             showShortenBox(false);
           }
         });
   }
 }