Google新登录,onActivityResult()未调用

时间:2018-02-10 22:10:38

标签: android android-activity google-signin google-oauth2 google-authentication

解释

我已根据official tutorial实施了Google登录流程,并且只有已登录到设备的帐户才能正确验证。当用户选择“使用其他帐户”或者在输入用户凭据后设备上没有存储Google帐户时,会再次显示登录屏幕,但不会触发onActivityResult()。在我返回登录屏幕并尝试再次点击Google登录按钮时,我GoogleSignInStatusCode 12502 SIGN_IN_CURRENTLY_IN_PROGRESS获得了onClick 12502,但大部分时间它只是在此时正常验证或不什么都不做case R.id.googleLoginButton: googleSignIn(); break; public void googleSignIn() { mIsResolving = true; Intent signInIntent = mGoogleSignInClient.getSignInIntent(); this.startActivityForResult(signInIntent, RC_GOOGLE); } @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { callbackManager.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data); switch (requestCode) { case RC_HINT: // Drop into handling for RC_READ case RC_READ: if (resultCode == RESULT_OK) { boolean isHint = (requestCode == RC_HINT); Credential credential = data.getParcelableExtra(Credential.EXTRA_KEY); processRetrievedCredential(credential, isHint); } else if (resultCode == 1001){ //user chose a different account } else { Log.e(TAG, "Credential Read: " + resultCode); Toast.makeText(this, "Credential Read Failed", Toast.LENGTH_LONG).show(); Crashlytics.log("Credential Read Failed"); } mIsResolving = false; break; case RC_SAVE_PASSWORD_AUTH: if (resultCode == RESULT_OK) { return; } else { Log.e(TAG, "Credential Save: NOT OK"); Toast.makeText(this, "Credential Save Failed", Toast.LENGTH_LONG).show(); Crashlytics.log("Credential Save Failed"); } mIsResolving = false; break; case RC_GOOGLE: Log.d(TAG, "RC_GOOGLE"); Log.d(TAG, resultCode + ""); Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data); handleSignInResult(task); break; default: Log.d(TAG, "default case onActivityResult, requestCode " + requestCode + ", resultCode " + resultCode ); Crashlytics.log("default case onActivityResult, requestCode " + requestCode + ", resultCode " + resultCode ); break; } }

缩写代码:

android:noHistory

我尝试过的故障排除:

我必须在AndroidManifest.xml中将startActivityForResult()更改为false,以允许该应用返回登录屏幕。使用和不使用this时也尝试setResult()。我尝试使用startActivityForResult而不是Intent进行了更改,尝试了几个onActivityResult()标记,检查了我的清单中是否存在可能阻碍SplashScreen的xml标记,已检查LoginSignupActivity对于可能会阻止onActivityResult()的代码,Log.d前面唯一的活动,添加了onActivityResult,这导致了在这种情况下没有调用callbackManager但是在所有其他情况下工作,在onActivityResult()中使用和不使用constructor (props) { super(); this.state ={ token: "X", val: ["","","","","","","","",""] }; } intelligentComputerPlay () { this.setState({ val: [ this.state.token, this.state.val[1], this.state.val[2], this.state.val[3], this.state.val[4], this.state.val[5], this.state.val[6], this.state.val[7], this.state.val[8] ]; });进行尝试,在function prompt { $origLastExitCode = $LASTEXITCODE $curPath = $ExecutionContext.SessionState.Path.CurrentLocation.Path if ($curPath.ToLower().StartsWith($Home.ToLower())) { $curPath = "~" + $curPath.SubString($Home.Length) } Write-Host "$env:UserName" -NoNewline -ForegroundColor Cyan Write-Host "@" -NoNewline -ForegroundColor Yellow Write-Host "$(hostname)" -NoNewline Write-VcsStatus Write-Host "`n$curPath" -NoNewline $LASTEXITCODE = $origLastExitCode " $('>' * ($nestedPromptLevel + 1)) " } Import-Module posh-git $global:GitPromptSettings.BeforeText = " (" $global:GitPromptSettings.AfterText = ")" $global:GitPromptSettings.EnableWindowTitle = "posh-git ~" $global:GitPromptSettings.EnableStashStatus = $true $global:GitPromptSettings.BeforeStashText = " {" $global:GitPromptSettings.AfterStashText = "}" $global:GitPromptSettings.BeforeStashForegroundColor = "Yellow" $global:GitPromptSettings.AfterStashForegroundColor = "Yellow" $global:GitPromptSettings.BranchUntrackedSymbol = "::" $global:GitPromptSettings.BranchGoneStatusSymbol = "~~" $global:GitPromptSettings.BranchIdenticalStatusToSymbol = "==" $global:GitPromptSettings.BranchAheadStatusSymbol = "<<" $global:GitPromptSettings.BranchBehindStatusSymbol = ">>" $global:GitPromptSettings.BranchBehindAndAheadStatusSymbol = "><" 中尝试删除Smart Lock以及其他各种无效的代码。

2 个答案:

答案 0 :(得分:1)

我错过了Intent的{​​{1}}标记,该标记已添加到从我的启动画面调用的实用程序函数中。

答案 1 :(得分:0)

从您的 Gmail 登录活动清单文件中删除 android:noHistory="true"

这对我有用。