Android Question Including images from xui.DefaultFolder in a Webview local page

Derek Johnson

Active Member
Licensed User
Longtime User
I'm trying to include an image located in the xui.DefaultFolder in a locally created webpage as shown in the following code:

B4X:
Sub Button1_Click
    File.Copy(File.DirAssets,"test.png",xui.DefaultFolder,"xyz.png")
    Log("Copied file")
    'How do I refer to the file xyz.png in the html?
    Dim link = "file:///xyz.png" 'What is the correct format for this link?
    html=$"<!DOCTYPE html>
<HTML><HEAD><title>Webview Test</title>
</head>
<h1>Webview Test with images in Internal Directory</h1>
<P>
<img src="${link}" width = "90%" alt="Oops! Couldn't show image!" >
</body></html>
"$
    WebView1.LoadHtml(html)
End Sub

The alt text is always displayed.

What format should the link to the file take in order for this to work?
 

Derek Johnson

Active Member
Licensed User
Longtime User
Is this a limitation imposed by targetSdkVersion="30"?

I'm creating an image of a bar code that I want to display in a Webview. Perhaps I will have to find a way of doing this without using a file.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

Derek Johnson

Active Member
Licensed User
Longtime User
This maybe helps?

Thank you but unfortunately that does not help. The problem exists in both Release mode and Debug mode.

Also the file that I am trying to access is in the xui default folder, having been created on the fly by B4A code and not the Assets folder.
 
Upvote 0
Top