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);
}
});
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With