0
I am using the following code to download files in web view:
@SuppressLint("InlinedApi")public void onDownloadStart(String url,String userAgent,String contentDisposition,String mimetype,long contentLength){
DownloadManager.Request request =new DownloadManager.Request(Uri.parse(url));
request.allowScanningByMediaScanner();final String filename =URLUtil.guessFileName(url, contentDisposition, mimetype);
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, filename);
request.setDestinationInExternalPublicDir("/Download", filename);DownloadManager dm =(DownloadManager) getSystemService(DOWNLOAD_SERVICE);
dm.enqueue(request);Intent intent =new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("*/*");
Toast.makeText(getApplicationContext(),"Baixando",
Toast.LENGTH_LONG).show();}}); //
The same is working normally on Android 4.0 ICS, but on Android 6.0 nothing happens. In this case, it would be necessary to perform downloads on Android 6.0?
Thank you Marcelo, after your answer I really believe that this is it. I’m trying to add your code to mine but I’m having some problems and I had to modify it a lot, I’m afraid it won’t work right away, but I’m already accepting your answer as correct. Thanks.
– jefferson
Of course...you will have to adapt mainly if you are using Ragment but this is the core.... hopefully it can work, at least it’s a start so you can search for more information. Good luck.
– Marcelo López