android如何将图像从互联网下载到本地存储?
我想将图像从URL internet下载到本地存储,并将图像从本地存储打开到imageview 我看到了这些答案 我知道我们可以使用毕加索和滑翔和凌空和通用图像加载器来完成这些工作,还有其他库 但是我无法实现下载图像的代码!在互联网上找不到任何新的例子。 我找到了毕加索图书馆的一些老例子旧版本android如何将图像从互联网下载到本地存储?,android,image,url,save,internal-storage,Android,Image,Url,Save,Internal Storage,我想将图像从URL internet下载到本地存储,并将图像从本地存储打开到imageview 我看到了这些答案 我知道我们可以使用毕加索和滑翔和凌空和通用图像加载器来完成这些工作,还有其他库 但是我无法实现下载图像的代码!在互联网上找不到任何新的例子。 我找到了毕加索图书馆的一些老例子旧版本 您能告诉我从URL internet下载图像到本地存储的新代码吗?或关于此主题的任何教程使用下载管理器从链接(从internet)下载图像 试试这个 使用此渐变: 并检查这一点:从服务器下载文件,
您能告诉我从URL internet下载图像到本地存储的新代码吗?或关于此主题的任何教程使用下载管理器从链接(从internet)下载图像 试试这个 使用此渐变:
并检查这一点:从服务器下载文件,您共享的所有链接有什么问题?看起来很全面…@Matt Clark我无法实现下载图像的代码。。。在互联网上找不到任何新的。。。我发现了一些毕加索图书馆的老版本,为什么你不能实现它?你找不到新的例子是什么意思?那篇文章有下载的确切代码…@Matt Clark就像毕加索一样,这是毕加索的旧版本。with(MainActivity.class).load(myPhoto).into(毕加索图像目标(getApplicationContext(),“imageDir”,“my_image.jpeg”);你还没有解释你的问题是什么,或者为什么你不能实施这些解决方案。也许你应该走了。
DownloadManager downloadManager = (DownloadManager) ((Activity) context).getSystemService(Context.DOWNLOAD_SERVICE);
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI | DownloadManager.Request.NETWORK_MOBILE)
.setAllowedOverRoaming(false)
.setTitle(fileName)
.setDescription("file description")
.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED)
.setDestinationInExternalPublicDir(imgStoragePath, fileName)
.setVisibleInDownloadsUi(true);
BroadcastReceiver onComplete = new BroadcastReceiver() {
public void onReceive(Context ctxt, Intent intent) {
//Download complete
}
};
context.registerReceiver(onComplete, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));
downloadManager.enqueue(request);