Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dowloading image resources from https with LoopJ AndroidAsyncHttp

I'm using LoopJ AndroidAsyncHttp to download images but when I try it for HTTPS URLs I get no response. Code:

AsyncHttpClient client = new AsyncHttpClient();
client.get(httpsUrlString, new BinaryHttpResponseHandler(allowedContentTypes) {
    @Override
    public void onSuccess(byte[] fileData) {
        Bitmap bitmap = BitmapFactory.decodeByteArray(fileData, 0, fileData.length);
        image.setImageBitmap(bitmap);
    }
});
like image 301
luigi23 Avatar asked Oct 09 '13 10:10

luigi23


1 Answers

There are a few open source libraries that do asynchronous image loading. They do not only take care of the download, but also caching and multithreading.

All in all, it is much more handy to use this libraries than to try to write all that code on your own. Right now it is only downloading an image, but in the future you may want caching, etc.

I suggest you take a look at picasso or volley, picasso is simpler to use, but volley has a lot more functionality.

like image 51
shalafi Avatar answered Oct 06 '22 19:10

shalafi