How can I get a MIME type from a web view?

I am going to develop a browser plugin that determines if a page is WML, and if so, it will be converted to HTML via the API.

What I want to do is to override onPageFinished in a WebViewClient and get the MIME type from the WebView . But in these two classes such methods do not exist.

Am I missing something or are there any other approaches? Any recommendations given would be appreciated.

+4
source share
2 answers

I just came up with an idea and it seems to work.

Load javascript with loadUrl when the page finishes loading ( onProgressChange up to 100%). Js code is similar to

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

You can try using MimeTypeMap

getFileExtensionFromUrl() followed by getMimeTypeFromExtension()

+2
source

All Articles