The situation is the following:
The activity started on app's launch (let's call it splash activity, because used for some checkings and for read/write some settings) is made by frameworks and the last one of them has firebase signInWithEmailAndPassword whose addOnCompleteListener contains the code for starting a new activity (let's say the main activity).
one of the options of the (so called) main activity's menu is firebase signOut, when i tap it the current user signs out but the signInWithEmailAndPassword (coded into the last fragment of previous activity) is called again!
is it because i splitted sign-in and sign-out in two different activities?
can anybody kindly help me with that, thanks in advance.
here is code schema:
FirebaseAuth.getInstance().signInWithEmailAndPassword(email, password)
.addOnCompleteListener(getActivity(), new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
// read some data from realtime database
database
.getReference(path)
.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
get snapshot data ...
// Store them into shared preferences
mSettings
.edit()
.putStringSet("STRING_SET_KEY", dataSet)
.apply();
// Update some Realtime database data
database
.getReference(path)
.updateChildren(newData)
.addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()) {
// Start new activity
Intent intent = new Intent(getActivity(), MainActivity.class);
startActivity(intent);
}
});
});
});
});
}
});
});
p.s. - i noticed because the signOut() kicks out the firebase user and when the signInWithEmailAndPassword is called again i got an error because it's not possible to read realtime database