0

I create an adnroid webview, to load url from server:

webView.loadUrl("http://ipaddress/myapp");

On my php server, i want to load image from android asset :

<img src="file:///android_asset/bigimage.png" />

When i run the app, the image didn't show on webview. How to handle this ? i want to speed up loading time by store big image on android asset.

  • Possible duplicate of [How to show local picture in web page?](https://stackoverflow.com/questions/4908171/how-to-show-local-picture-in-web-page) – InsaneCat Jun 21 '18 at 10:39

1 Answers1

0

So, it sounds like what you are trying to do is have the webView load a local resource rather than downloading from the server. The shouldOverrideUrlLoading call within the WebViewClient class is meant for just this.

You'll need to implement your custom WebViewClient class to do this. In the shouldOverrideUrlLoading method, you would check the URL and, if available, return the resource from your local assets.

SBerg413
  • 14,515
  • 6
  • 62
  • 88
  • I think you mean `shouldInterceptRequest`, right? Also, WebView by default handles `file:///android_asset/` URLs (so it's not clear what is wrong with the setup). – nfischer Apr 21 '19 at 02:54