我正在将 Google SSO 集成到我的 Android 应用中。我想知道何时提示用户选择帐户对话框并决定单击背景,因此该对话框被关闭。
选择帐户对话框由以下各项触发:
@Override
public void onConnected(Bundle connectionHint) {
Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
Activity activity = MyActivity.getActivity();
activity.startActivityForResult(signInIntent, RC_GET_TOKEN);
}
我正在使用 onActivityResult,但我不知道如何区分登录失败和对话框关闭。
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RC_GET_TOKEN) {
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
if (result.isSuccess()) {
//do something
} else {
// This is where I get when sign in fails, or when user dismisses the dialog
}
}
}
非常感谢您的帮助,谢谢,Giora。