0
I’d like to exhibit a Toastwhen the user does logout.
I have this structure:
Within ConexaoFirebase, I have a method called logOut:
public static void logOut() {
firebaseAuth.signOut();
}
and within the class PerfilActivity, I have a method that calls the logOut():
private void eventoClicks(){
btnLogOut.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ConexaoFirebase.logOut();
finish();
}
});
}
I wish every time it was done logout, were displayed a Toast, then I tried the following:
Within ConexãoFirebase, I created a method called alert:
private void alert(String s) {
Toast.makeText(getApplicationContext(), s, Toast.LENGTH_SHORT).show();
}
and within logOut called the alert passing the message that I want to be displayed, but my code got error:
What is the correct way to display the message?
I know I could do the Toast inside CadastrarActivity, but would like to do within the class ConexaoFirebase.


Pass the
contextfor the methodslogOutandalert: Ex:ConexaoFirebase.logOut(context);. and alsoalert(context, "Mensagem");– Valdeir Psr
Could you give me a better example? not yet manjo programming.
– Fabio Souza
The point is that the
Toastwill be shown in aActivityeven if the starting point in it is not aActivty. So you just have to get past the context of thatActivitywhere you want to launch theToast– Isac