开发者

Android WebView can render HTML going forward, but not backward

开发者 https://www.devze.com 2022-12-27 13:29 出处:网络
I\'m using a WebViewClient that overrides shouldOverrideUrlLoading so the browsing stays inside the WebView.I initially call loadDataWithBaseURL with some HTML I have in memory, which has links in it.

I'm using a WebViewClient that overrides shouldOverrideUrlLoading so the browsing stays inside the WebView. I initially call loadDataWithBaseURL with some HTML I have in memory, which has links in it. When I click the links, they load correctly in the webView.

Everything is good up till now, but when I press back, effectively calling webView.goBack(), the webView loads the failUrl I passed to loadDataWithBaseURL.

Why do开发者_JAVA技巧es it work going forward, but not going backward?


I found a solution, but I still feel like this is still an Android bug. You just have to keep track of the depth of browsing and when it gets to 0 you have to call loadDataWithBaseURL rather than webView.goBack(). Seems like a hack though.

0

精彩评论

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