本文介绍了此代码是否正确。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
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();
}
}
}
推荐答案
HttpResponse responseFromServer = httpClient.execute(postMethod);
int status = responseFromServer.getStatusLine().getStatusCode();
检查状态变量。
Check the status variable.
这篇关于此代码是否正确。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!