title: Java jersey RESTful webservice requests
body: <p>I've been following a tutorial about a restful service and it works fine. However there are something I dont quite understand yet. This is how it looks:</p>
  
  <pre><code>@Path("/hello")
  public class Hello {
  
      // This method is called if TEXT_PLAIN is request
      @GET
      @Produces( MediaType.TEXT_PLAIN )
      public String sayPlainTextHello() 
      {
          return "Plain hello!";
      }
  
      @GET
      @Produces( MediaType.APPLICATION_JSON )
      public String sayJsonTextHello() 
      {
          return "Json hello!";
      }
  
      // This method is called if XML is request
      @GET
      @Produces(MediaType.TEXT_XML)
      public String sayXMLHello() {
          return "&lt;?xml version=\"1.0\"?&gt;" + "&lt;hello&gt; Hello Jersey" + "&lt;/hello&gt;";
      }
  
      // This method is called if HTML is request
      @GET
      @Produces(MediaType.TEXT_HTML)
      public String sayHtmlHello() 
      {
          return "&lt;html&gt; " + "&lt;title&gt;" + "Hello fittemil" + "&lt;/title&gt;"
                  + "&lt;body&gt;&lt;h1&gt;" + "Hello!" + "&lt;/body&gt;&lt;/h1&gt;" + "&lt;/html&gt; ";
      }
  } 
  </code></pre>
  
  <p>Whats bothering me is that I can't make use of the right operations. When I request the service from a browser the appropriate sayHtmlHello() method gets called. But now I am developing an android application which I want to get the result in Json. But when I call the service from the application, the MediaType.TEXT_PLAIN method gets called. My android code looks similar to this:</p>
  
  <p><a href="https://stackoverflow.com/questions/3505930/make-an-http-request-with-android">Make an HTTP request with android</a></p>
  
  <p>How can call the method which uses MediaType.APPLICATION_JSON from my android application?
  Further I would like to make that particular method return an object, would be great if I got some guidance there as well.</p>