Ion koush library

452 views Asked by At

I'm trying to save image from url to a new File with ion library. But nothing happens. Can anybody help me with it?

Ion.with(mContext)
                .load("someUrl")
                .write(new File(mContext.getCacheDir(), "123.jpg"));
2

There are 2 answers

0
Pravin Raj On

Use Universal Image Loader

You can do it by

ImageLoader imageLoader = ImageLoader.getInstance(); // Get singleton instance

// Load image, decode it to Bitmap and return Bitmap to callback
imageLoader.loadImage(imageUri, new SimpleImageLoadingListener() {
    @Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage){
    // Do whatever you want with Bitmap
}
});
1
koush On

Ion is asynchronous. Use .setCallback to get a callback when it completes.

Ion.with(mContext)
                .load("someUrl")
                .write(new File(mContext.getCacheDir(), "123.jpg"));
                .setCallback(....)