How do I get the web page contents from a WebView?

后端 未结 7 1827
北恋
北恋 2020-11-22 06:19

On Android, I have a WebView that is displaying a page.

How do I get the page source without requesting the page again?

It seems WebView

7条回答
  •  囚心锁ツ
    2020-11-22 07:17

    I managed to get this working using the code from @jluckyiv's answer but I had to add in @JavascriptInterface annotation to the processHTML method in the MyJavaScriptInterface.

    class MyJavaScriptInterface
    {
        @SuppressWarnings("unused")
        @JavascriptInterface
        public void processHTML(String html)
        {
            // process the html as needed by the app
        }
    }
    

提交回复
热议问题