我是android和firebase的新手。我正在学习使用firebase的用户身份验证功能。我想要做的是让用户在按下撤销按钮后再次使用他们的用户名和密码登录。我正在使用firebase的示例java文件中的代码块。我的问题是这样 - 即使用户按下撤销按钮,也会出现选择帐户对话框,用户只需选择帐户而无需输入用户名,忘记密码。
private FirebaseAuth mAuth; /*firebase authorization object*/
private GoogleApiClient mGoogleApiClient;
private boolean isAccntConnected;
.
.
.
revokeBtn = (Button)findViewById(R.id.revoke_google);
mAuth = FirebaseAuth.getInstance();
.
.
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken(getString(R.string.default_web_client_id))
.requestEmail()
.build();
mGoogleApiClient = new GoogleApiClient.Builder(this)
//.enableAutoManage(this /*FragmentActivity*/, this/*OnConnectionFailedListener*/)
.addApi(Auth.GOOGLE_SIGN_IN_API,gso)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
.
.
.
private void revokeAccess() {
//First we sign out of Firebase
mAuth.signOut();
//Next we sign out of google
if (mGoogleApiClient.isConnected()) {
mGoogleApiClient.clearDefaultAccountAndReconnect();
Auth.GoogleSignInApi.signOut(mGoogleApiClient).setResultCallback(
new ResultCallback<Status>() {
@Override
public void onResult(Status status) {
Log.d(TAG, "Sign Out using Google Api.");
mGoogleApiClient.disconnect();
//CALL TO DISCONNECT GoogleApiClient
isAccntConnected = false;
}
});
}
//Next we revoke google access
Auth.GoogleSignInApi.revokeAccess(mGoogleApiClient).setResultCallback(
new ResultCallback<Status>() {
@Override
public void onResult(@NonNull Status status) {
//update the user interface by removing the revoke google button
findViewById(R.id.revoke_google).setVisibility(View.GONE);
}
}
);
.
.
.
@Override
protected void onStart(){
super.onStart();
mGoogleApiClient.connect();
}
.
.
.
@Override
public void onConnected(@Nullable Bundle bundle){
this.isAccntConnected = true;
}