Until Android 10.0 I managed to download, save and display images in ImageView with this code:
B4X:
Dim J As HttpJob
j.Initialize("", Me)
j.Download("http://www." & cUrl.Trim & "/images/produtos/PRD" & cImg.SubString2(nlen, 13+nlen) & ".jpg")
Wait For (j) JobDone(jo As HttpJob)
If j.Success Then
Try
imgProd.Bitmap = j.GetBitmap
lErr = False
Catch
ToastMessageShow("Erro 03: " & LastException.Message, True)
Log(LastException.Message)
End Try
End If
After the last update it stoped working.
Any better tip on how to donwload, save and display photos?
have you set up cleartext in your manifest. search for "cleartext" in the little box above. http is not allowed by default. only https. you have to specifically allow http
I added these lines to manifest, but with no success.
B4X:
' 28 - Non-ssl (non-https) communication is not permitted by default.
' It can be enabled in B4A v9+ by adding this line to the manifest editor:
CreateResourceFromFile(Macro, Core.NetworkClearText)
SetApplicationAttribute(android:usesCleartextTraffic, "true")
So I stopped using http:// (changed to https://).
Without try/catch I got this error:
I added these lines to manifest, but with no success.
B4X:
' 28 - Non-ssl (non-https) communication is not permitted by default.
' It can be enabled in B4A v9+ by adding this line to the manifest editor:
CreateResourceFromFile(Macro, Core.NetworkClearText)
SetApplicationAttribute(android:usesCleartextTraffic, "true")
So I stopped using http:// (changed to https://).
Without try/catch I got this error:
Yes. It is correct.
I have just managed to download and save a picture using FileProvider.
I also managed to share it via Whatsapp (just to test).
I only could not make the image show in ImageView, but I believe I am getting close.