Skip to main content
adicionou 1 caractere ao conteúdo
Fonte Link

Estou utilizando o seguiteseguinte código para baixar arquivos na 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();}}); //

O mesmo está funcionando normalmente no Android 4.0 ICS, mas no Android 6.0 não acontece nada. Nesse caso, que seria necessário para realizar downloads no Android 6.0?

Estou utilizando o seguite código para baixar arquivos na 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();}}); //

O mesmo está funcionando normalmente no Android 4.0 ICS, mas no Android 6.0 não acontece nada. Nesse caso, que seria necessário para realizar downloads no Android 6.0?

Estou utilizando o seguinte código para baixar arquivos na 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();}}); //

O mesmo está funcionando normalmente no Android 4.0 ICS, mas no Android 6.0 não acontece nada. Nesse caso, que seria necessário para realizar downloads no Android 6.0?

Fonte Link

Baixar arquivos na WebView no android 6.0

Estou utilizando o seguite código para baixar arquivos na 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();}}); //

O mesmo está funcionando normalmente no Android 4.0 ICS, mas no Android 6.0 não acontece nada. Nesse caso, que seria necessário para realizar downloads no Android 6.0?