iwanabeguru
Lurker
Hi all
I am trying to send requests to a server in JSON format but my app die on the emulator when i try to send request. However the same code works fine as a normal java application.
Here is my code:
What wrong with this code if it run perfectly in a java application?
Thank you for your help!
I am trying to send requests to a server in JSON format but my app die on the emulator when i try to send request. However the same code works fine as a normal java application.
Here is my code:
Code:
private HttpResponse doRequest(String url,JSONObject jso){
HttpClient client = new DefaultHttpClient();
HttpPost request = new HttpPost(url);
HttpResponse response = null;
try{
StringEntity se = new StringEntity(jso.toString());
se.setContentEncoding("UTF-8");
se.setContentType("application/json");
request.setEntity(se);
}
catch (UnsupportedEncodingException uee){
}
try {
response = client.execute(request);
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return response;
}
What wrong with this code if it run perfectly in a java application?
Thank you for your help!