class RequestTask extends AsyncTask { @Override protected String doInBackground(FixitRequest... fixitRequests) { Log.d(Constants.TAG, "Entering RequestTask"); HttpClient httpclient = new DefaultHttpClient(); HttpResponse response; String responseString = null; try { response = httpclient.execute(new HttpGet(fixitRequests[0].getUrl())); StatusLine statusLine = response.getStatusLine(); if (statusLine.getStatusCode() = = HttpStatus.SC_OK) { ByteArrayOutputStream out = new ByteArrayOutputStream(); response.getEntity().writeTo(out); out.close(); responseString = out.toString(); } else { //Closes the connection. response.getEntity().getContent().close(); throw new IOException(statusLine.getReasonPhrase()); } // TODO: Save the picture on the server. } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } Log.d(Constants.TAG, "Exiting RequestTask"); return responseString; } @Override protected void onPostExecute(String result) { super.onPostExecute(result); //Do anything with response.. } }
ResponseString = out.toString()
out.close()