Firebase 退出
变量初始化
private GoogleApiClient mGoogleApiClient;
当你把注销按钮放在 onCreate()
方法时,你必须要写这个代码。
mGoogleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */)
.addApi(Auth.GOOGLE_SIGN_IN_API)
.build();
在注销按钮上放下代码。
Auth.GoogleSignInApi.signOut(mGoogleApiClient).setResultCallback(
new ResultCallback<Status>() {
@Override
public void onResult(Status status) {
FirebaseAuth.getInstance().signOut();
Intent i1 = new Intent(MainActivity.this, GoogleSignInActivity.class);
startActivity(i1);
Toast.makeText(MainActivity.this, "Logout Successfully!", Toast.LENGTH_SHORT).show();
}
});