我的应用程序适用于 android 2.3.3 但它在 android 4.1.2 中强制关闭 下面是我将数据从 android 设备发送到服务器的代码。
HttpEntity entity;
HttpClient client = new DefaultHttpClient();
String url ="http://67.23.166.35:80/android/insertv2.php";
HttpPost request = new HttpPost(url);
StringEntity se = new StringEntity(datatoServer);
se.setContentEncoding("UTF-8");
se.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE,"application/json"));
entity = se;
request.setEntity(entity);
HttpResponse response = client.execute(request);
entity = response.getEntity();