Android Question OkHttpUtis2 library and HttpJob strange problem

GiovanniPolese

Well-Known Member
Licensed User
Longtime User
I commonly use OkHttpUtils2 library to call a WebService that I did on my site. Today I had a bad surprise, which seems not have an easy to find explanation.
Usually, in a BrowSer, the working call is:


In B4A, i use:
B4X:
Dim Url as string : Url="http://www.mysite.it/MyWebService/MywebService.asmx"
Dim ReqString as string:  ReqString="Request=..."
Dim JobTrasm as HttpJob
JobTrasm.PostString(Url,ReqString)

The App runs on devices with Internet SimCards, but, in Italian SimCard, I get JobTrasm.Success = true, while in Portuguese SimCard it return false. If I use the same Sim giving HotSpot to a computer, and issue the abovementioned "Http://www.mysite.it..." call, it works. The only not working case is in the B4A App and the JobTrasm error is:

java.net.UnknownServiceException: CLEARTEXT communication to www.mysite.it not permitted by network security policy

As I wrote, it seems not to be strictly related to the use of the Portuguese (only) sim card, but to the use of it with B4A, and, probably, with Vrsion 12.00. As a matter of fact I never had this problem before the last upgrade to Version 12.

Thanks in advance for any hint.
 

GiovanniPolese

Well-Known Member
Licensed User
Longtime User
Have you added this in mifesteditor:

SetApplicationAttribute(android:usesCleartextTraffic, "true")
Then I put this instruction in manifest, and not the MarcoRome suggested one, and also this works. I don't know why, but both solutions seem valid. Thanks to all.
 
Upvote 0

mcqueccu

Well-Known Member
Licensed User
Longtime User
Then I put this instruction in manifest, and not the MarcoRome suggested one, and also this works. I don't know why, but both solutions seem valid. Thanks to all.
Its the same thing packaged as macro. so just use the first one
 
Upvote 0
Top