title: Sending HTTP Get and Post request from android without httpClient
body: <p>I trying to consume a webservice rest from and Android app, but when I look for examples and found only two ways, with httpClient which is deprecated and I can't even import for my application for it version, and, a method with HttpURLConnection which, doesn't work like expected.</p>
  
  <p>My code right in this moment:</p>
  
  <pre><code>import java.io.IOException;
  import java.net.HttpURLConnection;
  import java.net.URL;
  
  public class RestConnect  {
      public static String listar() throws IOException {
         try {
             URL reqURL = new URL("http://localhost/wsRest/index.php/contact");
             HttpURLConnection request = (HttpURLConnection) (reqURL.openConnection());
             request.setRequestMethod("GET");
             request.connect();
  
          } catch (Exception e) {
              return "Nope!";
          }
          return "YESSSS!";
      }
  }
  </code></pre>
  
  <p>How can I access my URL and easily get it content, which Get and Post methods?</p>
  
  <p>Much thanks everyone!</p>