【发布时间】:2017-09-25 20:35:28
【问题描述】:
我想关闭获取请求连接,但是没有关闭。
这是我的代码块
编辑代码块但不再工作..
try {
HttpClient client = new DefaultHttpClient();
URI website = website = new URI("http://"+IPAdres+"/?Arduino="+Komut);
HttpGet request = new HttpGet();
request.setURI(website);
HttpResponse response = client.execute(request);
HttpEntity entity = response.getEntity();
EntityUtils.consume(entity);
request.abort();
client.getConnectionManager().shutdown();
client.getConnectionManager().closeExpiredConnections();
} catch (URISyntaxException e) {
Toast.makeText(MainActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
} catch (ClientProtocolException e) {
Toast.makeText(MainActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
} catch (IOException e) {
Toast.makeText(MainActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
}
我想在请求后关闭连接
【问题讨论】:
标签: java android http httpclient androidhttpclient