Now, let's see how we can make the functionality work:
- Declare the FirebaseAuth reference, plus add another variable that we will need later on:
FirebaseAuth auth; private static final int RC_SIGN_IN = 17;
- Now, inside your onCreate method, add the following code:
auth = FirebaseAuth.getInstance(); if(auth.getCurrentUser() != null) { Log.d("Auth", "Logged in successfully"); } else { startActivityForResult( AuthUI.getInstance() .createSignInIntentBuilder() .setAvailableProviders( Arrays.asList(new AuthUI.IdpConfig.Builder( AuthUI.EMAIL_PROVIDER).build())).build(), RC_SIGN_IN);findViewById(R.id.logoutBtn) .setOnClickListener(this);
- Now, in your activity, implement the View.OnClick listener. So your class will look ...