所以伙计们,我是一个菜鸟,所以请多多包涵,我想在应用程序中下载多个图像,我正在尝试为此使用下载管理器类。我必须下载大约 100-150 个图像,但是当它尝试下载 5- 10张图片它工作正常但是当我尝试下载更多文件时应用程序崩溃但下载继续我该如何正确地做到这一点请大家帮助我这是我用来下载图片的代码:-
public void downloadimages(String url,String filename)
{
String ur1=url,v1=filename;
downloadManager = (DownloadManager)getSystemService(DOWNLOAD_SERVICE);
Uri Download_Uri = Uri.parse(ur1);
DownloadManager.Request request = new DownloadManager.Request(Download_Uri);
request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI);
request.setAllowedOverRoaming(false);
request.setDescription("Android Data download using DownloadManager.");
request.setDestinationInExternalFilesDir(getApplicationContext(),Environment.DIRECTORY_DOWNLOADS,v1 + ".jpg");
downloadManager.enqueue(request);
}