How to show an image in a webviewer


#1

Hi there,
I would like to show an image in webviewer.
I tried this in the html file (developpement path):
<img src=file:///mnt/sdcard/AppInventor/assets/imagename.png>
but it didn’t work.


#2

is the html file you like to display also in the assets?
just use this path then
<img src="imagename.png">
in case you do not use a html file, see here https://puravidaapps.com/snippets.php#2ani
Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.


#3

Thank for your answer Taifun.
I tried that too but it didn’t work.
In fact i’m not using a real html file, i pass the html code through a call webviewer.LoadHtml.
The image is imported in the media (so i assume it’s in the assets folder).
I also tried your solution : file:///mnt/sdcard/AppInventor/assets/imagename.png
I got a broken link image response.


#5

I don’t know if the LoadHtml method will work for this
You can try to create a html file including some JavaScript, which will display the image dynamically via the webviewstring property
put that html file into the assets and call it using the GoToUrl method
Taifun


#8

Tried that but i got this answer : file:///mnt/sdcard/AppInventor/assets/WebViewString.html exposed beyond app through Intent.getData()


#9

It would really help if you provided a screenshot of your relevant blocks, so we can see what you are trying to do, and where the problem may be.

Taifun


#10

ListSort.php create the html file content (just some text and two images) when UpdateSortList is clicked
Then call Web5
WebViewString get the responseContent
Then the WebViewString is passed to the WebViewer1
The javascript in the html proceeds with the WebViewString and shows its content

The WebViewString.html file in media is:

<html>
<script>
    document.write(window.AppInventor.getWebViewString());
</script>
</html>

With that code nothing appears in the webviewer and i got this error message: file:///mnt/sdcard/AppInventor/assets/WebViewString.html exposed beyond app through Intent.getData()

With the other solution wich pass all the html content directly trought the webviewer, the text is then visible but the images are not (broken link signal in the webviewer). the code is almost the same, i just use webviewer.LoadHtml instead of webviewer.GoToUrl (and no WebViewString is required).


#11

does the example work for you?
How does the property Webviewer.WebViewString work?
Taifun