Android Question Access pics in file.dirassets from an html page.

MitchBu

Well-Known Member
Licensed User
Longtime User
My help file is an html in File.DirAssets, which uses a dozen or so pictures and video. I don't seem to be able to address them in HTML, although they are in files.dirassets together with the html page.

I suspect they are in compressed form, and need to be extracted somehow. I searched the forum to no avail, though.
 
Last edited:

rosippc64a

Active Member
Licensed User
Longtime User

 
Last edited:
Upvote 0

MitchBu

Well-Known Member
Licensed User
Longtime User
Unfortunately, this does not answer my question.

I already use WebViewAssetFile to load the html file.

My question has to do with the html code, which needs to point to image files that need to be next to the html file in order to display.

Apparently, Android does not store the pictures files "as is", since they do not show.

I read carefully https://www.b4x.com/android/forum/t...g-rapid-”-b4a-3-50-version.38981/#post-230988 but even adding #DebuggerForceStandardAssets: true to the project, and compiling as Release, the html file does not find the pictures I added to DirAsset next to it.
 
Upvote 0

rosippc64a

Active Member
Licensed User
Longtime User
I tried a small app with pics (in emulator). maybe there are things unnecessary, and works only in release mode.
Now works in debug mode with

#DebuggerForceStandardAssets: true


perfect.
 

Attachments

  • htmlfile.zip
    233 KB · Views: 262
Last edited:
Upvote 0

smhosseiniiii

New Member
hi
file:///android_asset/image.jpg' ---------------------ok
file:///android_asset/foldername/image.jpg' -------------------not ok

please help
 
Upvote 0

Ferdari

Active Member
Licensed User
Longtime User
User XUI.FileUri, it's that simple...

B4X:
WebView1.LoadHtml($"<img src="${xui.FileUri(File.DirAssets, "smiley.png")}" />"$)
'or:
WebView1.LoadUrl($"${xui.FileUri(File.DirAssets, "smiley.png")}"$)
what if files are in AssetDir/images/picture.jpg, i mean inside a folder in assets?
i tried
B4X:
xui.FileUri(File.DirAssets & "/images","important-wr.png")
'and
xui.FileUri(File.DirAssets,"images/important-wr.png")

none worked, i don't want to drop my images folder to root, i have a lot of images and it will be a mess, also i have CSS and Javascript folders that cannot be accessed.
 
Upvote 0

Peter Simpson

Expert
Licensed User
Longtime User
i don't want to drop my images folder to root,
It does not matter what you 'don't want', read my response below.

what if files are in AssetDir/images/picture.jpg, i mean inside a folder in assets?
Simple, place ALL FILES in the root like you are supposed to.

You NEED to flatten the assets folder by placing all the files in the root folder directly. You're supposed to manage the images through the IDE via the Files Tab. You create new groups/folders via the files tab and manage the files and folder names there. It's as simple as that.
 
Last edited:
Upvote 0

Ferdari

Active Member
Licensed User
Longtime User
It does not matter what you 'don't want', read my response below.


Simple, place ALL FILES in the root like you are supposed to.

You NEED to flatten the assets folder by placing all the files in the root folder directly. You're supposed to manage the images through the IDE via the Files Tab. You create new groups/folders via the files tab and manage the files and folder names there. It's as simple as that.
That can work, but if i have different images with same names in different sub folders, it wont work., i better followed Erel suggestion: add a zip and extract to Internal, i don't know why in B4A v10.70 the dir assets are broken and doubled the work for my webview apps.
 
Upvote 0

MitchBu

Well-Known Member
Licensed User
Longtime User
That can work, but if i have different images with same names in different sub folders, it wont work., i better followed Erel suggestion: add a zip and extract to Internal, i don't know why in B4A v10.70 the dir assets are broken and doubled the work for my webview apps.


There is yet another possibility: put all your pages on a web space.


Web sites come dirt cheap these days, for instance on https://www.hostgator.com/
 
Upvote 0
Top