此代码是否正确。

编程入门 行业动态 更新时间:2024-10-23 11:29:12
本文介绍了此代码是否正确。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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.

更多推荐

此代码是否正确。

本文发布于:2023-11-08 07:03:51,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1568676.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:是否正确   代码

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!