android – Google Plus登录“选择帐户”对话框出现两次

android – Google Plus登录“选择帐户”对话框出现两次,第1张

概述我正在通过开发人员文档实施Google登录.在我选择要使用错误RESOLUTION_REQUIRED(错误代码6)登录的帐户后,我的onConnectionFailed方法被调用.这将启动另一个“选择一个帐户”对话框,如果我选择相同的帐户,该对话框将起作用(转到我的权限).我不确定为什么它会提示另一个对话框.我从resolveSignInError开始有任何见解? 此外,从“选择一个帐户”中选择一 我正在通过开发人员文档实施Google登录.在我选择要使用错误RESolUTION_required(错误代码6)登录的帐户后,我的onConnectionFailed方法被调用.这将启动另一个“选择一个帐户”对话框,如果我选择相同的帐户,该对话框将起作用(转到我的权限).我不确定为什么它会提示另一个对话框.我从resolveSignInError开始有任何见解?

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

@OverrIDepublic 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();        }    }}@OverrIDepublic 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登录“选择帐户”对话框出现两次所遇到的程序开发问题。

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

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1136054.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-30
下一篇 2022-05-30

发表评论

登录后才能评论

评论列表(0条)

保存