• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

How to add download listener in webview

Sure, here's the code explaining how to attach a download listener to your WebView:

Code:
webView.setDownloadListener(new DownloadListener() {
           public void onDownloadStart(String url, String userAgent,
                           String contentDisposition, String mimetype,
                           long contentLength) {

                                         Uri uri = Uri.parse(url);
          Intent intent = new Intent(Intent.ACTION_VIEW,uri);
                   startActivity(intent);
           }
   });
 
Android Studio will auto-import any required packages for you.
 
Back
Top Bottom