Android Question [SOLVED] API 30 - Showing Image inside webView not working

mc73

Well-Known Member
Licensed User
Longtime User
Hi, after updating my app to API30, my images inside a webView are not displayed (I get the blank image). Wondering if I'm missing a new permission here.

B4X:
Dim imagePath As String=xui.FileUri(Cache.GetDirectory,myImage)
webView1.LoadHtml($"<HTML><HEAD></HEAD><BODY><IMG SRC="${imagePath}"></BODY></HTML>"$)

In this example, I'm using cache, but same thing happens with using dirInternal.
 

Computersmith64

Well-Known Member
Licensed User
Longtime User
Hi, after updating my app to API30, my images inside a webView are not displayed (I get the blank image). Wondering if I'm missing a new permission here.

B4X:
Dim imagePath As String=xui.FileUri(Cache.GetDirectory,myImage)
webView1.LoadHtml($"<HTML><HEAD></HEAD><BODY><IMG SRC="${imagePath}"></BODY></HTML>"$)

In this example, I'm using cache, but same thing happens with using dirInternal.
This might point you in the right direction -> https://stackoverflow.com/questions/66072416/webview-on-android-11-not-showing-local-image-files

- Colin.
 
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
Last edited:
Upvote 0

Computersmith64

Well-Known Member
Licensed User
Longtime User
Unfortunately it didn't work (the first suggestion for base 64).
The second suggestion however, worked, and I'm pretty happy for it, thank you!
B4X:
webView1.Initialize("webview1")
Private wvsetttings As WebViewSettings
wvsetttings.setAllowFileAccess(webView1,True)
I'll mark this thread as solved.
Oh - yeah I was referring to the accepted answer on the thread I posted the link to. Should have been more specific...

- Colin.
 
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
The simplest way to show a large image is with SimpleMediaManager + ZoomImageView.
True. However in my case I had to use the webView cause I set it as a container to many different reports. Surely in the near future I'll try to reconstruct my app and get away from the webView, since I see more and more problems with it.
 
Upvote 0

bobbruns

Member
Licensed User
Longtime User
This change with the upgrade to SDK 29+ caught me. The minute I compiled with SDK31 my app broke. I wanted to load a web page with an image, but you must set:

wvsetttings.setAllowFileAccess(YOURNAMEFORWEBVIEW,True) for SDK >29 for the image tag to work correctly (<img src= xxx.png" alt = "alt">).

I had to use webview here. I am not having any issues with other content, which is created using internal memory and text strings, but the image from an internal file would not load.

Google changed the default setting from true to false apparently as a precaution against fraud. PayPal will not allow their website to be accessed anymore with webviews.

Apple iOS webview is not affected and still works fine.

The library is here:

Of course you can set it back with b4xpages_disappear if you want. I sure would like to hear any other solutions.
 
Upvote 0
Top