这里将数据发布到 url 并从中获取响应。但是现在在这里放置代码得到 noHttpResponse 异常
TextView xx = (TextView) findViewById(R.id.xx);
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(
"http://motinfo.direct.gov.uk/internet/jsp/ECHID-Internet-History-Request.jsp");
try {
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(3);
nameValuePairs
.add(new BasicNameValuePair(
"Vehicle registration mark from number plate",
"123456789"));
nameValuePairs.add(new BasicNameValuePair("MOT test number",
"AP3398"));
nameValuePairs.add(new BasicNameValuePair("MOT test number",
"000000"));
post.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = client.execute(post);
String line = "";
if (response != null) {
System.out
.println("***********************************************************");
xx.setText(EntityUtils.toString(response.getEntity()));
}
} catch (IOException e) {
e.printStackTrace();
}
这里添加logcat
09-11 12:40:22.086: I/InputDispatcher(61): Application is not responding: AppWindowToken{406a9208 token=HistoryRecord{4064bf48 com.example.xxx/.MainActivity}}. 640698.7ms since event, 640698.2ms since wait started
09-11 12:40:22.086: I/WindowManager(61): Input event dispatching timed out sending to application AppWindowToken{406a9208 token=HistoryRecord{4064bf48 com.example.xxx/.MainActivity}}
09-11 12:40:27.117: I/InputDispatcher(61): Application is not responding: AppWindowToken{406a9208 token=HistoryRecord{4064bf48 com.example.xxx/.MainActivity}}. 645729.5ms since event, 645728.9ms since wait started
09-11 12:40:27.117: I/WindowManager(61): Input event dispatching timed out sending to application AppWindowToken{406a9208 token=HistoryRecord{4064bf48 com.example.xxx/.MainActivity}}
09-11 12:40:32.165: I/InputDispatcher(61): Application is not responding: AppWindowToken{406a9208 token=HistoryRecord{4064bf48 com.example.xxx/.MainActivity}}. 650777.7ms since event, 650777.1ms since wait started
09-11 12:40:32.165: I/WindowManager(61): Input event dispatching timed out sending to application AppWindowToken{406a9208 token=HistoryRecord{4064bf48 com.example.xxx/.MainActivity}}
09-11 12:40:37.182: I/InputDispatcher(61): Application is not responding: AppWindowToken{406a9208 token=HistoryRecord{4064bf48 com.example.xxx/.MainActivity}}. 655793.8ms since event, 655793.3ms since wait started
09-11 12:40:37.183: I/WindowManager(61): Input event dispatching timed out sending to application AppWindowToken{406a9208 token=HistoryRecord{4064bf48 com.example.xxx/.MainActivity}}
09-11 12:40:42.202: I/InputDispatcher(61): Application is not responding: AppWindowToken{406a9208 token=HistoryRecord{4064bf48 com.example.xxx/.MainActivity}}. 660814.3ms since event, 660813.7ms since wait started
09-11 12:40:42.202: I/WindowManager(61): Input event dispatching timed out sending to application AppWindowToken{406a9208 token=HistoryRecord{4064bf48 com.example.xxx/.MainActivity}}