There are several ways to log out:
1. FirebaseUI: Refarence
Add Dependencies:
dependencies { implementation 'com.firebaseui:firebase-ui-auth:4.0.0' }
Then:
public void onClick(View v) { if (v.getId() == R.id.sign_out) { AuthUI.getInstance() .signOut(this) .addOnCompleteListener(new OnCompleteListener<Void>() { public void onComplete(@NonNull Task<Void> task) {
2. Kotlin: Link
Use default Android authentication dependency, for example: com.google.firebase:firebase-auth:16.0.1
firebase.auth().signOut().then(function() {
3. By default with Java:
Use default Android authentication dependency, for example: com.google.firebase:firebase-auth:16.0.1
FirebaseAuth mAuth = FirebaseAuth.getInstance(); try { mAuth.signOut(); Toast.makeText(this, "User Sign out!", Toast.LENGTH_SHORT).show(); }catch (Exception e) { Log.e(TAG, "onClick: Exception "+e.getMessage(),e ); }
source share