Android Question HELP read data from home server esp

SyncM

Member
B4X:
Private Sub Button1_Click
    
    Dim result As String
    
    Dim j As HttpJob
    Dim k As OkHttpRequest
    Dim h As OkHttpClient

    

    j.Initialize("", Me)
    j.Download("http://192.168.4.1:1234/rd_dan_san")
    
    Wait For (j) JobDone(j As HttpJob)
    
    If j.Success Then
        result=j.GetString
    Else
        result="ERROR"   
    End If
    
    Label1.Text=result
    
    
End Sub

In this code the response is ERROR
 
Upvote 0

SyncM

Member
Регистратор подключен к: Xiaomi 23021RAA2Y
--------- beginning of main
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = true **
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
** Activity (main) Resume **
*** Receiver (httputils2service) Receive (first time) ***
ResponseError. Reason: java.net.UnknownServiceException: CLEARTEXT communication to 192.168.4.1 not permitted by network security policy, Response:

full code
B4X:
#Region  Project Attributes
    #ApplicationLabel: B4A Example
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Private xui As XUI
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    Private Button1 As Button
    Private Label1 As Label
   
   

End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("Layout")
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub



Private Sub Button1_Click
   
    Dim result As String
   
    Dim j As HttpJob
    Dim k As OkHttpRequest
    Dim h As OkHttpClient

   

    j.Initialize("", Me)
    j.Download("http://192.168.4.1:1234/rd_dan_san")
   
    Wait For (j) JobDone(j As HttpJob)
   
    If j.Success Then
        result=j.GetString
    Else
        result="ERROR"  
    End If
   
    Label1.Text=result
   
   
End Sub
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
ResponseError. Reason: java.net.UnknownServiceException: CLEARTEXT communication to 192.168.4.1 not permitted by network security policy, Response:
You already got told to add
B4X:
CreateResourceFromFile(Macro, Core.NetworkClearText)
in #6 from Erel.
Do it and try again
 
Upvote 0
Top