Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Use this code in doInBackground
- HttpClient client = new DefaultHttpClient();
- String urlx = "http://10.0.2.2:64466/api/Products/1";
- URL url = new URL(urlx);
- URI uri = new URI(url.getProtocol(), url.getUserInfo(),
- url.getHost(), url.getPort(), url.getPath(),
- url.getQuery(), url.getRef());
- url = uri.toURL();
- Log.v("Async Task", "url is: " + url);
- HttpGet request = new HttpGet(url.toString());
- HttpResponse response = client.execute(request);
- StatusLine statusLine = response.getStatusLine();
- int statusCode = statusLine.getStatusCode();
- if (statusCode == 200) {
- HttpEntity entity = response.getEntity();
- if (entity != null) {
- InputStream instream = entity.getContent();
- String jsonResult = RestClient
- .convertStreamToString(instream);
- Log.e("Result","Json: "+jsonResult)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment