Android Question OkHttpUtils2 stop working

gatetec

New Member
Hello everyone..
I'm new to B4A and I think this is very nice program but now I run into trouble.
The code use php and make a post request to a server.
I need help to understand why my code work in NOX player but not when I connect my Android phone with B4A Bridge.
I got it work on the phone but 3 days ago it's not work any more.
Maybe I have change some setups but I start to get crazy and really need some help.


Get Data from mysql:
Sub Read_data
    Try
        'Dim PageServer As String = "http://iotproyecto.epizy.com/datasend.php"
        'iotproyecto.epizy.com/datasend.php?act=Save&ppm=4.66&tem=57.8&rad=200
        Dim PageServer As String = "http://gatetec.se/bidata/datasend.php"
        'PageServer = "http://gatetec.se/bidata/datasend.php"
        'inserta todas las Filas
        Dim js As HttpJob
        js.Initialize("", Me)
        js.download2(PageServer, Array As String ("act", "R1"))
    
        Wait For (js) JobDone(js As HttpJob)
        If js.Success Then
            Dim res As String
            res = js.GetString
            Dim parser As JSONParser
            parser.Initialize(res)
            If res <> False Then
                Dim Tabla As List
                Tabla = parser.NextArray                           
                Dim Fila As Map
                Dim Temp,ppm,fecha,radiacion, salida As String
                'Select N,`fecha`,`ppm`,`temperatura`,`radiacion` From `tabla` order by N Desc Limit 1
                For i=0 To Tabla.size-1
                   Fila =  Tabla.Get(i)
                    Temp = Fila.Get("temperatura")
                    ppm = Fila.Get("ppm")
                    radiacion = Fila.Get("radiacion")
                    fecha =  Fila.Get("fecha")
                    salida = "Fecha: " & fecha & CRLF _
                       & "Temp: " & Temp & CRLF _
                       & "ppm: " & ppm & CRLF _
                       & "radiacion: " & radiacion
                    MsgboxAsync(salida,"Datos Leidos")
                    MsgboxAsync(Temp,"Datos Leidos")
                Next
                                            
            End If
        
        End If
    Catch
        Log(LastException)
    End Try
    
    
End Sub
 

gatetec

New Member
Run in debug mode and see what happens. Maybe the download fails.
Hello Erel, thank's for fast answer.
The code still work in NOX but not in Xiaomi MI 10.
As the code was working in the phone 3 days ago I suspect that I have done something but I don't know what.
I have tried to connect to local server but it's the same.
I have debug and get following in the log.

Logger connected to: Xiaomi Mi 10
--------- beginning of system
--------- beginning of main
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
ResponseError. Reason: java.net.UnknownServiceException: CLEARTEXT communication to gatetec.se not permitted by network security policy, Response:
ResponseError. Reason: java.net.UnknownServiceException: CLEARTEXT communication to gatetec.se not permitted by network security policy, Response:
ResponseError. Reason: java.net.UnknownServiceException: CLEARTEXT communication to gatetec.se not permitted by network security policy, Response:
** Activity (main) Pause, UserClosed = false **
Copying updated assets files (1)
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
ResponseError. Reason: java.net.UnknownServiceException: CLEARTEXT communication to gatetec.se not permitted by network security policy, Response:
** Activity (main) Pause, UserClosed = false **

I have following permissions:
android.permission.INTERNET
 
Upvote 0

gatetec

New Member
Hello Erel, thank's for fast answer.
The code still work in NOX but not in Xiaomi MI 10.
As the code was working in the phone 3 days ago I suspect that I have done something but I don't know what.
I have tried to connect to local server but it's the same.
I have debug and get following in the log.

Logger connected to: Xiaomi Mi 10
--------- beginning of system
--------- beginning of main
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
ResponseError. Reason: java.net.UnknownServiceException: CLEARTEXT communication to gatetec.se not permitted by network security policy, Response:
ResponseError. Reason: java.net.UnknownServiceException: CLEARTEXT communication to gatetec.se not permitted by network security policy, Response:
ResponseError. Reason: java.net.UnknownServiceException: CLEARTEXT communication to gatetec.se not permitted by network security policy, Response:
** Activity (main) Pause, UserClosed = false **
Copying updated assets files (1)
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
ResponseError. Reason: java.net.UnknownServiceException: CLEARTEXT communication to gatetec.se not permitted by network security policy, Response:
** Activity (main) Pause, UserClosed = false **

I have following permissions:
android.permission.INTERNET

I HAVE SOLVED IT !!!!!
I added following to manifest...
CreateResourceFromFile(Macro, Core.NetworkClearText)
 
Upvote 0
Top