When the app is running foreground, the online will set to true and when the app is in background, the online will set to false. I have this code in all activity:
@Override
protected void onStart() {
super.onStart();
if (mAuth.getCurrentUser() != null) {
mUserDatabase.child("online").setValue("true");
}
}
@Override
protected void onStop() {
super.onStop();
if (mAuth.getCurrentUser() != null) {
mUserDatabase.child("online").setValue("false");
}
}
The problem is when I try to move to another activity the online is always set to false. Why is it always false?