I am trying to build a android application that gets data from a REST service as JSON.
I am using a PC , windows, eclipse and a android emulator.
In this function here below. If I use a URL that is live on the internet then it works perfectly.
HttpGet httpGet = new HttpGet("http://www.cheesejedi.com/rest_services/get_big_cheese.php?puzzle=1");
but if I use a url that is hosted locally ( using visual studio ) on my own pc I get a error saying "Conection refused."
HttpGet httpGet = new HttpGet("http://" + "localhost:50851/Default.aspx");
How do I connect to my local host? Thnaks
protected String doInBackground(Void... params) {
HttpClient httpClient = new DefaultHttpClient();
HttpContext localContext = new BasicHttpContext();
//HttpGet httpGet = new HttpGet("http://www.cheesejedi.com/rest_services/get_big_cheese.php?puzzle=1");
HttpGet httpGet = new HttpGet("http://" + "localhost:50851/Default.aspx");
//
String text = null;
try {
HttpResponse response = httpClient.execute(httpGet, localContext);
HttpEntity entity = response.getEntity();
text = getASCIIContentFromEntity(entity);
} catch (Exception e) {
return e.getLocalizedMessage();
}
return text;
}