title: Android Volley - Checking internet state
body: <p>Before I am using Volley, well as usual, I used AsyncTask to check my internet state.</p>
  
  <p>Here is what I did in AsyncTask:</p>
  
  <pre><code>private class NetCheck extends AsyncTask&lt;String, Void, Boolean&gt; {
  
      @Override
      protected Boolean doInBackground(String... args) {
          // get Internet status
          return cd.isConnectingToInternet();
      }
  
      protected void onPostExecute(Boolean th) {
          if (th == true) {
              new LoadCategories().execute();
          } else {
              Toast.makeText(CategoryActivity.this, "Unable to connect to server",
                      Toast.LENGTH_LONG).show();
          }
      }
  }
  </code></pre>
  
  <p>And this is <code>isConnectingToInternet</code> function:</p>
  
  <pre><code>public boolean isConnectingToInternet() {
      ConnectivityManager connectivity = (ConnectivityManager) _context.getSystemService(Context.CONNECTIVITY_SERVICE);
      if (connectivity != null) {
          NetworkInfo info = connectivity.getActiveNetworkInfo();
          if (info != null &amp;&amp; info.isConnected())    
              try {
                  URL url = new URL("http://www.google.com");
                  HttpURLConnection urlc = (HttpURLConnection) url
                          .openConnection();
                  urlc.setConnectTimeout(3000);
                  urlc.connect();
                  if (urlc.getResponseCode() == 200) {
                      return true;
                  }
              } catch (MalformedURLException e1) {
                  e1.printStackTrace();
              } catch (IOException e) {
                  e.printStackTrace();
              }
  
      }
      return false;
  }
  </code></pre>
  
  <p>How do I achieve this using Volley?</p>