我想要为了登录用户我必须使用这段代码:
Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient); startActivityForResult(signInIntent,RC_SIGN_IN);
注销@H_301_5@
new ResultCallback<Status>() { @Override public void onResult(Status status) { disconnect(); } });
解决方法
Here我找到了解决方案:
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); } }); }