2

I'm not exactly sure what my problem is. I using the code below to download a bunch of files:

public void DownloadNow(ArrayList<String> must_download)
{
    String serviceString = Context.DOWNLOAD_SERVICE;
    DownloadManager download;
    download = (DownloadManager)getSystemService(serviceString);

    for(int x = 0; x < must_download.size(); x++)
    {
        System.out.println("DOWNLOADING "+must_download.get(x).toString());
        Uri uri = Uri.parse("http://drm.csdev.nmmu.ac.za/Zandre/"+must_download.get(x).toString());
        DownloadManager.Request request = new DownloadManager.Request(uri);
        request.setDestinationInExternalFilesDir(this, Environment.DIRECTORY_DOWNLOADS, must_download.get(x).toString());
        request.setNotificationVisibility(Request.VISIBILITY_VISIBLE);
        request.setTitle(must_download.get(x).toString());
        long reference = download.enqueue(request);
    }
}

Where must_download is an ArrayList full of file names. This method has successfully worked in the past, until I tried to run it on a different thread. The thread idea did not work out so well, so I decided to switch back.

Now, the problem is this- since I switched back to the original method the Download Manager runs full time, downloading the same files over and over in an endless loop.The only way I can stop it is to **Disable the Download Manager, but then I can't download anything... What I've read so far and tried is

  1. Uninstall the app- still downloading...
  2. Switch device off and back on again- still downloading...
  3. Clear cache of Download Manager- still downloading...

Even after this has used all the devices mobile data, it still just carries on downloading.

Has anyone else encountered this type of problem? Any ideas solutions?

Code Vader
  • 739
  • 3
  • 9
  • 26
  • look into this [post](http://stackoverflow.com/q/14073323/3326331) and also [this](http://stackoverflow.com/a/20929717/3326331) – Sagar Pilkhwal Sep 08 '14 at 18:39
  • This may sound stupid, but have you tried to Rebuild the project? – Joaquim Ley Sep 08 '14 at 18:42
  • @Sagar, after reading those posts I think I have anidea of whats going on. When I did the downloads in another thread, I accidentally put it in an endless loop. Something like while(true){for loop which download;}. Is it possible that even after uninstalling app, switching of device, and clearing the cache of Download Manager, that the Download Manager is still stuck in that loop? – Code Vader Sep 08 '14 at 18:52
  • well after restart it should not be struck, but cant really tell what actually happened inside your application. if you want to remove the download, make use you use the download id – Sagar Pilkhwal Sep 08 '14 at 18:58

0 Answers0