0
     Button btn = (Button) findViewById(R.id.Savenotes);
    btn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
            request.allowScanningByMediaScanner();
            request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_ONLY_COMPLETION);

            DownloadManager manager = (DownloadManager) getApplicationContext().getSystemService(Context.DOWNLOAD_SERVICE);
            manager.enqueue(request);
        }

I am trying to download the contents which is present in webview.I am using download manager but nothing is happening.

Agniveer Kranti
  • 117
  • 2
  • 12

2 Answers2

0
webView.setDownloadListener(new DownloadListener()
  {
   public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength)
   {
    //for downloading directly through download manager
    Request request = new Request(Uri.parse(url));
    request.allowScanningByMediaScanner();
    request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
    request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "download");
    DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
    dm.enqueue(request);
   }
  });
Nirav Ranpara
  • 13,753
  • 3
  • 39
  • 54
0
webView.setDownloadListener(new DownloadListener() {
public void onDownloadStart(String url, String userAgent,
            String contentDisposition, String mimetype,
            long contentLength) {
    Intent i = new Intent(Intent.ACTION_VIEW);
    i.setData(Uri.parse(url));
    startActivity(i);
}});
Bhavin Jadav
  • 274
  • 1
  • 3
  • 14