I am trying to use a Firebase database with BroadcastReceiver to retrieve some data. Unfortunately, sometimes the user is null , which means that I cannot use the UID for the sample data.
@Override public void onReceive(final Context context, Intent intent) { FirebaseAuth.getInstance().addAuthStateListener(new FirebaseAuth.AuthStateListener() { @Override public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) { FirebaseUser user = firebaseAuth.getCurrentUser(); if(user != null){
Also FirebaseAuth.getInstance().getCurrentUser sometimes null . In addition, I do not run much time in my BroadcastReceiver . I am talking about getting one opjes without any nodes under it.
How can I use a Firebase database with BroadcastReceiver ?
android firebase-database firebase-authentication
Robin dijkhof
source share