title: Android Firebase - "onDataChange" And "onCancelled" Not Being Called With No Internet Connection
body: <p>In my app, I simply try to retrieve a reading passage from my <code>Firebase</code> database by adding a <code>ListenerForSingleValueEvent</code> in the following code:</p>
  
  <pre><code>myRef.child("passages").child(passageNum).addListenerForSingleValueEvent(new ValueEventListener() {
              @Override
              public void onDataChange(DataSnapshot dataSnapshot) {
                  System.out.println("ON DATA CHANGE");
              }
  
              @Override
              public void onCancelled(DatabaseError databaseError) {
                  System.out.println("DATABASE ERROR");
                  FirebaseErrorHandler.handleDatabaseError(databaseError.getCode(), ReadingActivity.this);
              }
  
          });
  </code></pre>
  
  <p>It works perfectly fine when there is internet connection. However, when I purposely turn off internet connection, neither <code>onDataChange</code> nor <code>onCancelled</code> are being called. This is very frustrating since two of the error codes in <code>databaseError.getCode()</code> have to do with network connectivity issues. </p>
  
  <p>If I can't get this data due to no internet, I want to at least let the user know that instead of having this listener hanging with the screen constantly loading. Is there a way to solve this? Would I have to just resort to <code>Firebase's</code> REST API? At least with RESTful network requests, they let you know if the connection failed or not.</p>