d0pestar
d0pestar

Reputation: 575

Ion koush library

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"));

Upvotes: 0

Views: 451

Answers (2)

koush
koush

Reputation: 2962

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(....)

Upvotes: 0

Pravin Raj
Pravin Raj

Reputation: 3599

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
}
});

Upvotes: 1

Related Questions