此外,从“选择一个帐户”中选择一个帐户会显示权限,如果我在此时点击取消并从拨号盘中选择另一个帐户,则会显示错误的权限图片或有时根本没有图片.我也得到了一次内部错误.
@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登录“选择帐户”对话框出现两次所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)