Android Question Where's the problem with DOWNLOAD in S20?

boten

Active Member
Licensed User
Longtime User
This puzzles me.
This is my piece of code:

B4X:
  dim sf,txt as String 
  sf="http://www.somesite.org/somefile.xml"
    
    Dim j As HttpJob
    j.Initialize("", Me)
    j.Download(sf)
    
    Wait For (j) JobDone(j As HttpJob)
        
    If j.Success Then
        txt=j.GetString
    j.Release
    ....
    do something with txt
    ....

    Else
        Msgbox("Comm. problem","error")
        j.Release
        Return
 End If

On an older machine (please don't laugh) Galaxy S4 android 4.4.2 it works like charm.
BUT on Galaxy S20 android 10 I get the comm. problem msg.
log says:

B4X:
ResponseError. Reason: java.net.UnknownServiceException: CLEARTEXT communication to www.somesite.org not permitted by network security policy, Response:

It is probably some setting on the device but which one? (or is it something else?)
 

MarcoRome

Expert
Licensed User
Longtime User
This puzzles me.
This is my piece of code:

B4X:
  dim sf,txt as String
  sf="http://www.somesite.org/somefile.xml"
  
    Dim j As HttpJob
    j.Initialize("", Me)
    j.Download(sf)
  
    Wait For (j) JobDone(j As HttpJob)
      
    If j.Success Then
        txt=j.GetString
    j.Release
    ....
    do something with txt
    ....

    Else
        Msgbox("Comm. problem","error")
        j.Release
        Return
End If

On an older machine (please don't laugh) Galaxy S4 android 4.4.2 it works like charm.
BUT on Galaxy S20 android 10 I get the comm. problem msg.
log says:

B4X:
ResponseError. Reason: java.net.UnknownServiceException: CLEARTEXT communication to www.somesite.org not permitted by network security policy, Response:

It is probably some setting on the device but which one? (or is it something else?)

if you search in B4X: "CLEARTEXT" you have a lot information.

1595500932486.png



Add this line to your Manifest:
SetApplicationAttribute(android:usesCleartextTraffic, "true")
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

boten

Active Member
Licensed User
Longtime User
Belated thanks. As it happened the site was HTTPS (and not HTTP) - working OK now
 
Upvote 0
Top