The following code, for the Android OS, will make a HTTP request to a JSON webservice at “url” and convert the response into a JSONObject.
DefaultHttpClient httpClient = new DefaultHttpClient(); HttpGet request = new HttpGet(url) ; ResponseHandler<String> responseHandler=new BasicResponseHandler(); String responseBody = httpClient.execute(request, responseHandler); JSONObject jsonResponse = new JSONObject(responseBody) ;
Advertisements