android - WebView loadDataWithBaseURL method cannot load images -
i have html string containing seveal img tags passing webview's loaddatawithbaseurl method like
string data = "some html <img> , <link>....."; wview.loaddatawithbaseurl("http://dummy.baseurl/", data, "text/html", "utf-8", null);
if dont pass first parameter html can displayed subsequent requests or css files not triggered thats why passing dummy baseurl.
running code when try requests made under shouldinterceptrequest() below
wview.setwebviewclient(new webviewclient() { @override public webresourceresponse shouldinterceptrequest(webview view, string url) { log.d("url="+url, "resources"); .... } });
the can see outputs
http://dummy.host.name/images/face.jpg etc
but original html contains ".." in img src <img src="../images/face.jpg">
trouble parent directory (..) part ignored webview
this ".." important me cannot figure out why skipping part
edit
i loading images zip file inside shouldinterceptrequest() can put necessary logic first should have correct src.
i noticed if path appended baseurl, ignored example
http://dummy.baseurl/one/two/
becomes (looking request logs)
http://dummy.baseurl/
i suspect if these 2 related !
where want load images from? if you're trying load them phone need use assets folder.
Comments
Post a Comment