Android Question How to download non-https url images with targetSdkVersion = "28"

Mikonios

Active Member
Licensed User
Our App needs images of some public urls that do not work with https, only through http.
After the change of Google in API 28 and aligning the user's security, the connection with non-https url is not allowed. Is there a way or alternative to download these ??

Thanks for the answers
 

Mikonios

Active Member
Licensed User
B4X:
Sub X01_DownTAIco
    Try
        For i = 0 To Main.MyPoisTA1.Size - 1
            Dim Values() As String = Main.MyPoisTA1.Get(i)
            Dim MyFile1 As String = "ta" & Csr.ExtraeCadena("." & Values(9), ".", ".", True) & ".png"
            If File.Exists(Main.DirIco, MyFile1) = False Then
                Dim j As HttpJob
                j.Initialize("Job******", Me)
                j.Download("http://******.***.**/*****/***/**********/" & Values(9))
                 
                Wait For (j) JobDone(j As HttpJob)
                If j.Success Then
                    'The result is a json string. We parse it and log the fields.
                    Dim MiFile2 As String = ""
                    Dim out As OutputStream        = File.OpenOutput(Main.DirIco, MyFile1, False )
                    Dim MiResult As InputStream = j.GetInputStream
                    File.Copy2(MiResult, out)
                    out.Close
                    Dim GIcon As Bitmap    = LoadBitmap(Main.DirIco, MyFile1)
                 
                    TblBitMap(i)    = GIcon
                    TblBmTxt(i, 0)    = MyFile1:    TblBmTxt(i, 1)= i
                 
                End If
                j.Release
            End If

        Next
        'X55_DownTASale("Test download.")
    Catch
        Log(LastException)
    End Try
    X05_DownTAIco
             
End Sub
 
Last edited:
Upvote 0

Star-Dust

Expert
Licensed User
add this in manifest
B4X:
CreateResourceFromFile(Macro, Core.NetworkClearText)

see this post
 
Upvote 0

Star-Dust

Expert
Licensed User
Upvote 0

Mikonios

Active Member
Licensed User
Manifest:
AddManifestText(
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="28"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
'End of default text.

CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)

AddApplicationText(
<uses-library android:name="org.apache.http.legacy" android:required="false" />
<meta-data android:name="com.google.android.geo.API_KEY" android:value=".................-BO3...7Q"/> )

' Por Problemas de memoria obligo al SDK al ser mayor en el background se liberará antes
SetApplicationAttribute(android:largeHeap,"true")
' ---------------------------------------- Por Problemas de memoria obligo al SDK OJO PARA SDK >= 10
 
Upvote 0

DonManfred

Expert
Licensed User
Upvote 0

Mikonios

Active Member
Licensed User
Solved! Thank you very much Star-Dust.
Tested and working
I had not read it correctly confusing with our entry in Manifesto.

add this in manifest
B4X:
CreateResourceFromFile(Macro, Core.NetworkClearText)

see this post

Thanks Manfred, if you don't tell me, I won't notice and I won't see it !!!
 
Upvote 0
Top