I developed a TV app and service a while ago, to track my media storage. the service sends data in JSON format. The wife got a new phone so I'm trying to consume the service from the android SDK. I tried the followinf code but I end up with truncated data:
// Send GET request to <service>/ GetSeriesListing HttpGet request = new HttpGet("http://192.168.0.1:1566/ MediaCatalogService.svc /GetSeriesListing"); request.setHeader("Accept", "application/json"); request.setHeader("Content-type", "application/json"); DefaultHttpClient httpClient = new DefaultHttpClient(); HttpResponse response = httpClient.execute(request); HttpEntity responseEntity = response.getEntity(); // Read response data into buffer char[] buffer = new char[(int)responseEntity.getContentLength()]; InputStream stream = responseEntity.getContent(); InputStreamReader reader = new InputStreamReader(stream); reader.read(buffer); stream.close(); String value = new String(buffer) return value; Can someone explain why the above truncates the data? I changed the code to this: // Send GET request to <service>/GetPlates HttpGet request = new HttpGet("http://192.168.0.1:1566/ MediaCatalogService.svc/GetSeriesListing"); request.setHeader("Accept", "application/json"); request.setHeader("Content-type", "application/json"); DefaultHttpClient httpClient = new DefaultHttpClient(); HttpResponse response = httpClient.execute(request); HttpEntity responseEntity = response.getEntity(); String value = EntityUtils.toString(responseEntity); This works however I have a question about the overhead of using the EntityUtils, is it much, ie should I be more focused on figuring out the truncation issue? -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en