Intercept and override HTTP requests from WebView

后端 未结 7 742
醉话见心
醉话见心 2020-11-30 17:54

I have a WebView in my application in which some site is opened (always the same, it is my own page). The site has some JS code which loads some images from the remote host.

相关标签:
7条回答
  • 2020-11-30 18:21

    As far as I know, shouldOverrideUrlLoading is not called for images but rather for hyperlinks... I think the appropriate method is

    @Override public void onLoadResource(WebView view, String url)

    This method is called for every resource (image, styleesheet, script) that's loaded by the webview, but since it's a void, I haven't found a way to change that url and replace it so that it loads a local resource ...

    0 讨论(0)
提交回复
热议问题