Skip to content Skip to sidebar Skip to footer

Androidhttpclient Can Not Getentity().getcontent() After Closed

public InputStream getInputStream() { AndroidHttpClient client = AndroidHttpClient.newInstance(USERAGENT); HttpUriRequest request = new HttpGet(url); InputStream in = n

Solution 1:

Like this, for instance:

public InputStream getInputStream() {
    AndroidHttpClientclient= AndroidHttpClient.newInstance(USERAGENT);
    HttpUriRequestrequest=newHttpGet(url);
    InputStreamin=null;
    try {
        HttpResponseresponse= client.execute(request);
        returnnewByteArrayInputStream(newEntityUtils.toByteArray(response.getEntity()));
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        client.close();
    }
}

Solution 2:

Check whether you have enabled the INTERNET Permission on your manifest file.

<uses-permissionandroid:name="android.permission.INTERNET"/>

Include the above line in your Androidmanifest.xml

Post a Comment for "Androidhttpclient Can Not Getentity().getcontent() After Closed"