Android Question WebView Not Refreshing Images

HimeAnator

Member
Licensed User
Longtime User
I've got a webview that I'm loading images into, but when the image changes the webview is not showing the new image, still the old one. The image keeps the same file name but the actual picture itself is changed.

The webview has its own activity and its closed using Activity.Finish and I've tried adding the following code in various places hoping it would reset it but no luck...
B4X:
        WebView1.LoadHtml("<html><body>Loading...</body></html>")

'And

WebView1.loadUrl("about:blank")


The image is loaded using this code...
B4X:
TempHtml="<html><body bgcolor='black' topmargin='0' leftmargin='0' marginwidth='0' marginheight='0'><center>" _
& "<img src=" & ImagePath & " width='95%' height='auto'/></center>" _
& "</body></html>"

WebView1.LoadHtml(TempHtml)
 

HimeAnator

Member
Licensed User
Longtime User
Are you calling WebView1.LoadHtml(TempHtml) again to refresh the image?

You can try to add a random parameter to the ImagePath:
B4X:
"<img src=""" & ImagePath & "?avoidcache=" & DateTime.Now & """ width ...

Yes I'm using WebView1.LoadHtml(TempHtml) to load the html page each time. I tried adding the
B4X:
"?avoidcache=" & DateTime.Now
like you suggested but it still kept loading the old image. I have added the code to a sub and used "callsubdelayed", with no luck. The only way the image refreshes if I completely close and reopen the application. Ive trapped the back key and call "Activity.finish" when the user presses the back key. I thought that closing the activity would clear webview1 but it didnt :/
 
Upvote 0
Top