Search code examples
javaandroid-studioandroid-download-manager

Android Java download manager no longer works


My code don't work anymore, because the Download manager don't accept the download link, but last Week the Download manager accept the link. Can someone helps me? I think Google change something... Thanks

change the link to someone other url(works)

DownloadManager.Request request = new DownloadManager.Request(Uri.parse("http://suggestqueries.google.com/complete/search?client=firefox&q=" + searchTo.getText().toString()));
request.setDestinationInExternalPublicDir("/open_serach_data/cache", "suggest.txt");
DownloadManager downloadManager = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
downloadManager.enqueue(request);

Solution

  • From Android 9.0 Its Changing You should use

            DownloadManager.Request request = new DownloadManager.Request(Uri.parse( url ));
    
            request.setDescription(title);
            request.setTitle(title);
    
    
            request.setDestinationUri(Uri.fromFile(f));
    
            img_d_id = manager.enqueue(request);