title: Firebase onDataChange not called opening application after some time
body: <p>I'm writing an Android application using Firebase Api 9.+.</p>
  
  <p>I use Firebase authentication and database.</p>
  
  <p>When I access my app and log in, all goes fine and data is retrieved correctly by the valueEventListeners.</p>
  
  <p>My problem starts when I access my app after some time and it is already logged in.</p>
  
  <p>Authentication seems to be confirmed, but none of my listeners is triggered and nothing seems to be retrieved.</p>
  
  <p>To get my application to work fine again I have to log out and log in again.</p>
  
  <p>I don't know if it's a "session expired" problem or something I forgot to write in my code.</p>
  
  <p>Here is one of my valueEventListeners:</p>
  
  <pre><code>DatabaseReference myFirebase = FirebaseDatabase.getInstance().getReference();
  hairDresserFirebase = myFirebase.getReference("hairDressers");
  hairDresserFirebase.addValueEventListener(new ValueEventListener() {
      @Override
      public void onDataChange(DataSnapshot dataSnapshot) {
          for (DataSnapshot snapshot : dataSnapshot.getChildren()){
              HairDresser hd = snapshot.getValue(HairDresser.class);
              if (hairDresserList.contains(hd)) hairDresserList.remove(hd);
              hairDresserList.add(hd);
          }
          mRecyclerView.getAdapter().notifyDataSetChanged();
      }
  
      @Override
      public void onCancelled(DatabaseError databaseError) {}
  });
  </code></pre>
  
  <p>The others change only for the reference.</p>
  
  <p>They are all in onCreateView() method of different fragments.</p>
  
  <p>This is the code executed int the onCreate() method of my splash activity to verify if user is already logged in:</p>
  
  <pre><code>mAuth = FirebaseAuth.getInstance();
  mAuthListener = new FirebaseAuth.AuthStateListener() {
      @Override
      public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
          FirebaseUser user = firebaseAuth.getCurrentUser();
          if (user == null) return;
          authenticated = true;
      }
  };
  </code></pre>
  
  <p>While my log in activity is launched only if user is not logged in and performs the full right procedure to log in with email and password or with facebook, and it works fine.</p>
  
  <p>I didn't find anything to solve this problem, I don't want to force my users to reauthenticate every single time they open my application.</p>
  
  <p>Please help me :)</p>