title: HttpURLConnection exception
body: <p>I have a method to check for internet connectivity within the device.The method always throws exception even though the mobile is connected to wifi/gprs. Do i need to add any 
  permission within xml or is the code gone wrong</p>
  
  <pre><code>public boolean checkConnectivity(String url)  {     
  
          try{                
  
              HttpURLConnection conn = (HttpURLConnection)new URL(url).openConnection();
              conn.setRequestMethod("HEAD");
  
                  if(conn.getResponseCode() == HttpURLConnection.HTTP_OK) {
                          return true;
                  }else{
                          return false;
                  }
  
          }catch(Exception e) {
                  System.out.println("myhttp exception");
                  return false;
          }                           
  }
  </code></pre>