下载Android中使用下载管理器类的多个文件? [英] downloading multiple files using downloadmanager class in android?

查看:218
本文介绍了下载Android中使用下载管理器类的多个文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用下载管理器类的android我有100-200图像文件,但是当我尝试下载文件,应用程序崩溃,但下载开始下载多个文件? 我该如何解决这个问题,我的$ C $下下载的文件是:

i want to download multiple files using downloadmanager class in android i have 100-200 image file but when i try to download the files app crashes but the download starts? how can i fix this,my code for downloading the files is:

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);     

        }
02-23 16:45:28.695: E/AndroidRuntime(22646): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.newpicker/com.example.newpicker.AnotherActivity}: java.lang.IndexOutOfBoundsException: Invalid index 136, size is 136

这是我的logcat

this is my logcat

推荐答案

您可以向我们展示了code com.example.newpicker.AnotherActivity 类,因为它看来,错误来自这个班。

Can you show us the code com.example.newpicker.AnotherActivity class, because it seems that the error comes from this class.

那么错误是 IndexOutOfBoundsException异常,让你尝试用更少的图像,例如10或20?并在以后执行时的第一个10被回收?

then the error is a IndexOutOfBoundsException, so have you tried with less image eg 10 or 20? and run later when the first 10 are recovered?

这篇关于下载Android中使用下载管理器类的多个文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆