此代码是否正确。 [英] This code correct or not.

查看:49
本文介绍了此代码是否正确。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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("http://localhost:50554/api/vetri?id="+Id+"&Imei="+Imei+"Btrylevel="+Battery);
            HttpPost httpPost1=new HttpPost("http://kredo.no-ip.org/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.


这篇关于此代码是否正确。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆