Android Json上传在三星设备上不起作用
我使用以下代码将Json对象上载到服务器Android Json上传在三星设备上不起作用,android,json,Android,Json,我使用以下代码将Json对象上载到服务器 public static User registerUser(User user) { HttpClient client = null; client = new DefaultHttpClient(); HttpPost post = new HttpPost( "http://www.someurl.com/update/"); post.setHeader("Accept", "app
public static User registerUser(User user) {
HttpClient client = null;
client = new DefaultHttpClient();
HttpPost post = new HttpPost(
"http://www.someurl.com/update/");
post.setHeader("Accept", "application/json");
post.setHeader("Content-type", "application/json");
JSONObject inputJson = new JSONObject();
try {
inputJson.put("name", user.getName());
inputJson.put("username", user.getUsername());
inputJson.put("email", user.getEmail());
inputJson.put("gender", user.getGender());
inputJson.put("location", user.getLocation());
inputJson.put("password", user.getPassword());
inputJson.put("deviceId", user.getDeviceId());
inputJson.put("contactNumber", user.getContactNumber());
inputJson.put("dateOfBirth", user.getDateOfBirth().getTime());
} catch (JSONException e) {
e.printStackTrace();
}
String input = inputJson.toString();
try {
post.setEntity(new StringEntity(input));
} catch (UnsupportedEncodingException e1) {
// handle exception
Log.d("registrattion", e1.getMessage());
}
HttpResponse response = null;
try {
response = client.execute(post);
Log.d("upload", "write");
} catch (IOException e) {
// handle exception
e.printStackTrace();
}
Log.d("res", response.getStatusLine().toString());
return user;
}
服务器未检测到任何Json调用。该代码适用于HTC和联想设备。它也适用于我国最常用的华为设备。它在三星设备上不起作用。可能有什么问题?并且您在logcat中没有任何错误,对吗?除非您对设备进行根目录检查,否则无法获取任何错误。如果您通过ADB在IDE中查看,则不需要根目录设备。由于某些原因,我无法使用ADB将应用程序安装到我的三星设备或从中读取logcat。我遇到了相同的问题,是否有任何解决方案更新?需要明确的是,有效的JSON将在LogCat中验证并从其他Android和iOS客户端收到。然而,我们的一个三星设备客户端正在向服务器发送某种JSON加密。加密/模糊数据的用户代理是:
Dalvik/1.6.0(Linux;U;Android 4.4.2;SAMSUNG-SM-G900A Build/KOT49H)