所以伙计们我是菜鸟所以请耐心等待我,我想在应用程序中下载多个图像,我正在尝试使用下载管理器类。我必须下载大约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);
}
答案 0 :(得分:1)
错误是IndexOutOfBoundsException
?所以你尝试用较少的图像,例如10或20?当前10个被恢复时运行?