Reputation: 575
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
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
Reputation: 3599
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