Search code examples
androidwebkitwebviewmime-typeswml

How could I get MIME type from a web view?


I'm about to develop a browser plugin that detects whether a page is WML and if so, it will be transformed to HTML via an API.

What I want to do is override onPageFinished in WebViewClient and get MIME type from WebView. But there seems no such kind of methods in those two classes.

Am I missing anything or are there some other approaches? Any advice given will be appreciated.


Solution

  • I have just come up with an idea and seems work.

    Load a javascript with loadUrl when the page is finish loading (onProgressChange to 100%). The js code is like

    javascript:(function() {
        var wml_root = document.getElementsByTagName('wml');
        if (wml_root && wml_root.length > 0) {
            // apply an XLST or do something here...
        }
    })()