I used the following piece of code to retrieve basically a JSON formatted String from a php page (www.ace.ucv.ro/android/android.php).
For some reason, no matter what I try, the string "result" remains empty, nothing is stored inside it, even when I use a special function to convert it from InputStream to String (with BufferedReader).
The String in which I want to store is called "RESULT".
public void connect(String url){
HttpClient client = new DefaultHttpClient();
HttpGet httpGet = new HttpGet(url);
HttpResponse response;
try{
response = client.execute(httpGet);
Log.i("Praeda", response.getStatusLine().toString());
HttpEntity entity = response.getEntity();
if(entity != null){
result = entity.getContent().toString();
}
if(entity == null){
result = "failed";
}
}catch(Exception e){
e.printStackTrace();
}
}
Any suggestions you might have would be great...
JSON response is normally gzipped, try this