Question

Im using onpagefinished method to show url to the edittext this works.but not properly because it gives me problems with (if url ends with mp4 show download dialog) the dialog won't show,maybe onpagefinished isn't showing the current url?

I also tried onLoadResource and onPagestarted methods but still same problem

wb.setWebViewClient(new WebViewClient() {
            public boolean shouldOverrideUrlLoading(WebView view,final String url) {
               if (url.endsWith(".mp4") { 
                                       //do smth }}}

wb.setWebViewClient(new WebViewClient() {
                            public void onPageFinished(WebView view, String url) {
                                          super.onPageFinished(view, url);
                                          urlEdit.setText(view.getUrl());
                } 
        });
Was it helpful?

Solution

This looks like it's not working because you are setting two different WebViewClients.

You should declare your WebViewClient and then set it like this:

WebViewClient mWebViewClient = new WebViewClient() {
    public boolean shouldOverrideUrlLoading(WebView view,final String url) {
        if (url.endsWith(".mp4") { 
            //do smth 
        }
    }
    public void onPageFinished(WebView view, String url) {
        super.onPageFinished(view, url);
        urlEdit.setText(view.getUrl());
    } 
};

wb.setWebViewClient(mWebViewClient);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top