Android Question OKHttpUtils2 can't download image from url with http.but https work fine(solved)

bjfhs

Active Member
Licensed User
Longtime User
I need work on a local area network,and download image show in a imageview.
ImageUrl = "http://www.b4x.com/basic4android/images/SS-2012-08-29_12.55.42.png"
DownloadImage(ImageUrl,ImageView1)
[CODE lang="b4x" title="show image"]Sub DownloadImage(Link As String, iv As ImageView)
Dim j As HttpJob
j.Initialize("", Me)
j.Download(Link)
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
iv.Bitmap = j.GetBitmap

Else
'StartActivity( Main)
Log(j.ErrorMessage)
End If
j.Release
End Sub[/CODE]
 
Last edited:
I need work on a local area network,and download image show in a imageview.
ImageUrl = "http://www.b4x.com/basic4android/images/SS-2012-08-29_12.55.42.png"
DownloadImage(ImageUrl,ImageView1)
[CODE lang="b4x" title="show image"]Sub DownloadImage(Link As String, iv As ImageView)
Dim j As HttpJob
j.Initialize("", Me)
j.Download(Link)
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
iv.Bitmap = j.GetBitmap

Else
'StartActivity( Main)
Log(j.ErrorMessage)
End If
j.Release
End Sub[/CODE]
Add the code into manifest file
B4X:
SetApplicationAttribute(android:networkSecurityConfig, @xml/network_security_config)
CreateResource(xml, network_security_config.xml,
<network-security-config>
<base-config cleartextTrafficPermitted="true">
    <trust-anchors>
        <certificates src="system" />
    </trust-anchors>
</base-config>
</network-security-config>
)
 
Upvote 0
Back
Top