I am learning Android now and I am working on how to fire a request and receive a result from server. What I am doing is
// Button Click Event
btnLogin.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
String testURL = "http://djs-corner.appspot.com/getClosestClubs?lat=40.7600624&lon=-73.98558";
// Create http GET method
HttpClient client = new DefaultHttpClient();
// Create http GET method
HttpGet getTest = new HttpGet(testURL);
// Fire a request
try {
HttpResponse response = client.execute(getTest);
int statusCode = response.getStatusLine().getStatusCode();
HttpEntity entity = response.getEntity();
InputStream is = entity.getContent();
String result = convertStreamToString(is);
Log.e("RESULT", result);
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Log.d("ClientProtocolException is ", e.toString());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Log.d("IOException is ", e.toString());
}
}
});
String convertStreamToString(InputStream inputStream) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null)
sb.append(line + "\n");
return sb.toString();
}
The result I am getting back is just partial of original result.Please look at the image at here. If we take a look at data from the above url, we can see that some of the data are chopped down. What i am doing wrong at here.