0

我正在尝试将图像从 url 保存到带有离子库的新文件中。但什么也没有发生。有人可以帮我吗?

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

2 回答 2

1

使用通用图像加载器

你可以这样做

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
}
});
于 2015-06-17T05:56:29.573 回答
0

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(....)
于 2015-06-18T04:57:13.247 回答