我创建了以下用于判断连接状态的函数:
private void checkConnectionStatus() {
HttpClient httpClient = new DefaultHttpClient();
try {
String url = "http://xxx.xxx.xxx.xxx:8000/GaitLink/"
+ strSessionString + "/ConnectionStatus";
Log.d("phobos", "performing get " + url);
HttpGet method = new HttpGet(new URI(url));
HttpResponse response = httpClient.execute(method);
if (response != null) {
String result = getResponse(response.getEntity());
...
当我关闭服务器进行测试时,执行程序排了很长时间的队
HttpResponse response = httpClient.execute(method);
有没有人知道如何设置超时以避免等待时间过长?
谢谢!