android - 从 android 应用中的 Google 集成注销

android - log out from Google integration in android app

我通过以下方式退出 google 集成:

 Auth.GoogleSignInApi.revokeAccess(mGoogleApiClient).setResultCallback(
                               new ResultCallback<Status>() {
                                   @Override
                                   public void onResult(Status status) {
                                       AndyConstants.loginorout = false;
                                       Intent intent = new Intent(getActivity(), HomeActivity.class);
                                       startActivity(intent);
                                   }
                               });

现在的问题是,在 onResult() 中,我开始 activity 名为 HomeAvtivity,但在注销后我被重定向到 activity(RegisterActivity),其中 google 登录存在按钮而不是 HomeActivity

我在 onResume() 中找到了未连接 GoogleApiClient 的解决方案,因此它崩溃了,因为 GoogleApiClient 为空。因此,只需将以下内容添加到您的代码中,上面的函数就会成功地从 google 集成中注销用户。

 @Override
    protected void onStart() {
        super.onStart();
        mGoogleApiClient.connect();
    }