Download in webview

 code:


_webview.setDownloadListener(new DownloadListener() { 

    @Override

        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.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, filename);

            DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);

dm.enqueue(request);

            Toast.makeText(getApplicationContext(), "Downloading File", //To notify the Client that the file is being downloaded

                    Toast.LENGTH_LONG).show();

        }

    });

Comments

Post a Comment

Popular posts from this blog

Background video in Sketchware