开发者

How could I get MIME type from a web view?

开发者 https://www.devze.com 2023-03-23 13:28 出处:网络
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.

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 su开发者_如何学编程ch kind of methods in those two classes.

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


You can try using MimeTypeMap's

getFileExtensionFromUrl() followed by getMimeTypeFromExtension()


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...
    }
})()
0

精彩评论

暂无评论...
验证码 换一张
取 消