B4J Question B4J WebView local html file loading with local pictures

MuuSer

Member
Licensed User
Longtime User
I have html file and corresponding png files in Files directory (yes - they are shown in IDE Files tab too). I can load html file via WebView LoadHtml:
B4X:
wv.LoadHtml(File.ReadString(File.DirAssets, "abi.html"))
but then I can't see images as:
B4X:
<img src="file:///android_asset/ikoon.png"/>
in html code will not help.

And of course WebView LoadUrl shows nothing:
B4X:
wv.LoadUrl("file:///android_asset/abi.html")
I must missing something, but I think that android_assets is not right place for B4J apps. I wasted already more than 2 hours to search a solution, but nothing. :(
 

billzhan

Active Member
Licensed User
Longtime User
I used:

B4X:
wv1.LoadUrl("file:///R:/jqdemo.htm")

R:/1.jpg   1.jpg and jqdemo.htm in the root folder  "R"
<img src="1.jpg">


when the file is in File.DirApp folder
url="file:///"&File.DirApp&"/jqdemo.htm"

not sure if this work with File.DirAssets
 
Upvote 0

MuuSer

Member
Licensed User
Longtime User
Thanks, billzhan,
but no - LoadUrl will not work that way with File.dirAssets.

What I want is just minimize file footprint of my program - just one standalone jar or exe without dependency files. But after digging through Google, seems that this is not possible. I hope that I'm wrong.

Best, what I can do now is use html file from my DirAssets by reading html code from that and then copying pictures from DirAssets to temporary folder and replace image sources in html code before using it with LoadHtml. Pity - why can't life be easier? :D

P.S.
Olalaa! I must have a total brain warming by seeking solutions for using pictures and html together from DirAssets by "easy way". Best of all what I can do, is just copy all files – html and pictures to temporary folder. Then I can avoid changing html source. Stupid me. :)
 
Last edited:
Upvote 0
Top