public InputStream getInputStream() {
AndroidHttpClient client = AndroidHttpClient.newInstance(USERAGENT);
HttpUriRequest request = new HttpGet(url);
InputStream in = null;
try {
HttpResponse response = client.execute(request);
in = response.getEntity().getContent();
return in;
} catch (IOException e) {
e.printStackTrace();
} finally {
client.close();
}
}
I put the this method in a Util class.
But when call getInputStream() in another class,I can’t get the InputSteam because of AndroidHttpClient is closed.
if I don’t close AndroidHttpClient, there appeared “leak found,AndroidHttpClient created and never closed”.
How to get the content in this situation
Like this, for instance: