title: How to deal with network issues
body: <p>One of my apps uses a lot of HTTP requests to communicate with its back-end.
  I use 2 different implementations to perform these requests:</p>
  
  <ul>
  <li>The library <code>Volley</code> for most cases</li>
  <li>A combination of <code>AsyncTask</code> and <code>DefaultHttpClient</code> for few cases</li>
  </ul>
  
  <p>Most of the time, everything works well. But sometimes I have a bunch of network exceptions raised and shown into Crashlytics:</p>
  
  <ul>
  <li><p><code>java.net.UnknownHostException: Unable to resolve host "mydomain.com": No address associated with hostname
  Caused by: libcore.io.GaiException: getaddrinfo failed: EAI_NODATA (No address associated with hostname)</code></p></li>
  <li><p><code>com.android.volley.ServerError
     at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:175)
     at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:110)</code></p></li>
  </ul>
  
  <p>With a bit of research, <strong>I found that this is supposed to happen when the device has a really bad 3g/4g or behind a VPN/subnetwork so it can't reach my website.</strong></p>
  
  <p>How do I make sure the device is really connected to internet?
  I actually perform these requests only if this function return true:</p>
  
  <pre><code>public static boolean isOnline(Context ctx) {
          ConnectivityManager cm = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE);
          NetworkInfo netInfo = cm.getActiveNetworkInfo();
          if (netInfo != null &amp;&amp; netInfo.isConnectedOrConnecting()) {
              return true;
          }
          return false;
  }
  </code></pre>
  
  <p>Or should I just let it go and assume it is normal to get up to few hundreds of these warning per month?</p>