本文介绍了此代码是否正确。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
protected void onCreate(Bundle savedInstanceState) { if (android.os.Build.VERSION.SDK_INT > 9) { StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); String IMEI="1234566"; String Phonemodel="Samsung"; HttpClient httpClient=new DefaultHttpClient(); // HttpPost httpPost=new HttpPost("localhost:50554/api/vetri?id="+Id+"&Imei="+Imei+"Btrylevel="+Battery); HttpPost httpPost1=new HttpPost("kredo.no-ip/SSMA/api/DevicesAPI/RegisterDevice?IMEI="+IMEI+"&Phonemodel="+Phonemodel); try { HttpResponse response=httpClient.execute(httpPost1); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } }
推荐答案
您好, 我建议检查服务器状态。您的错误是空的,但服务器已经响应。如何获得? 请添加此行: Hello, I recommend to check the server status. Your error is empty but there is respone from server. How to get it? Add this line please: HttpResponse responseFromServer = httpClient.execute(postMethod); int status = responseFromServer.getStatusLine().getStatusCode();
检查状态变量。
Check the status variable.
更多推荐
此代码是否正确。
发布评论