在这里我正在收集用户数据,现在我想在提到 url 的情况下发送这些数据。但是当我运行应用程序时,它会显示一个对话框并写为不幸查询已停止。请任何人知道如何发送数据任何 URL 请建议我。
try
{
JSONObject action=new JSONObject();
JSONObject user=new JSONObject();
action.put("person_name", Person_Name);
action.put("mobile_number", Mobile_Number);
action.put("person_query", Person_Query);
action.put("action", Action);
user.put("result",action);
jsonString1 =user.toString();
}
catch (Exception je)
{
}
Toast.makeTex(DetailsActivity.this,jsonString1,Toast.LENGTH_LONG).show();
// Sending JSON Over the Network
String wurl="http://www.androidbegin.com/tutorial/jsonpar.txt";
DefaultHttpClient httpclient = new DefaultHttpClient();
HttpPost httppostreq = new HttpPost(wurl);
StringEntity se = null;
try {
se = new StringEntity( jsonString1);
} catch (UnsupportedEncodingException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
se.setContentType("application/json;charset=UTF-8");
se.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "application/json;charset=UTF-8"));
httppostreq.setEntity(se);
try {
HttpResponse httpresponse = httpclient.execute(httppostreq);
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}