Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了android – Google Plus登录“选择帐户”对话框出现两次大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在通过开发人员文档实施Google登录.在我选择要使用错误RESOLUTION_required(错误代码6)登录的帐户后,我的onConnectionFailed方法调用.这将启动另一个“选择一个帐户”对话框,如果我选择相同的帐户,该对话框将起作用(转到我的权限).我不确定为什么它会提示一个对话框.我从resolveSignInError开始有任何见解?

此外,从“选择一个帐户”中选择一个帐户会显示权限,如果我在此时点击取消并从拨号盘中选择另一个帐户,则会显示错误的权限图片或有时根本没有图片.我也得到了一次内部错误.

@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
    if (!mIntenTinProgress) {
        // Store the ConnectionResult so that we can use it later when the user clicks
        // 'sign-in'.
        mConnectionResult = connectionResult;
        if (mSignInClicked) {
            // The user has already clicked 'sign-in' so we attempt to resolve all
            // errors until the user is signed in,or they cancel.
            resolveSignInError();
        }
    }
}

private void resolveSignInError() {
    if (mConnectionResult != null && mConnectionResult.hasResolution()) {
        try {
            mIntenTinProgress = true;
            starTintentSenderForResult(mConnectionResult.getResolution().geTintentSender(),RC_SIGN_IN,null,0);

        } catch (IntentSender.SendIntentexception E) {
            // ThE intent was canceled before it was sent.  Return to the default
            // state and attempt to connect to get an updated ConnectionResult.
            mIntenTinProgress = false;
            mGoogleApiClient.connect();
        }
    }
}

@Override
public void onActivityResult(int requestCode,int resultCode,Intent data) {
    super.onActivityResult(requestCode,resultCode,data);
    if (requestCode == RC_SIGN_IN) {
        if (resultCode != RESULT_OK) {
            mSignInClicked = false;
        }
        mIntenTinProgress = false;
        if (!mGoogleApiClient.isConnecTing()) {
            mGoogleApiClient.connect();
        }
    }
}

解决方法

以下代码对我来说工作正常,请用它更新你的并检查.
private void resolveSignInError() {
        if (mConnectionResult.hasResolution()) {
            try {
                mIntenTinProgress = true;
                mConnectionResult.startResolutionForResult(this,RC_SIGN_IN);
            } catch (SendIntentexception E) {
                mIntenTinProgress = false;
                mGoogleApiClient.connect();
            }
        }
    }

    @Override
    public void onConnectionFailed(ConnectionResult result) {
        if (!result.hasResolution()) {
            GooglePlayservicesUtil.getErrorDialog(result.getErrorCode(),this,0).show();
            return;
        }

        if (!mIntenTinProgress) {

            mConnectionResult = result;

            if (mSignInClicked) {

                resolveSignInError();
            }
        }

    }

    @Override
    protected void onActivityResult(int requestCode,int responseCode,Intent intent) {
        if (requestCode == RC_SIGN_IN) {
            if (responseCode != RESULT_OK) {
                mSignInClicked = false;
            }

            mIntenTinProgress = false;

            if (!mGoogleApiClient.isConnecTing()) {
                mGoogleApiClient.connect();
            }
        }
    }

大佬总结

以上是大佬教程为你收集整理的android – Google Plus登录“选择帐户”对话框出现两次全部内容,希望文章能够帮你解决android – Google Plus登录“选择帐户”对话框出现两次所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。