I guess there are a bug or problem with HTTPUtils2 when it's used under a service look here:
https://www.b4x.com/android/forum/threads/http_get-string.61081/
This specific code won't work if instead of put in main activity i put Main Activity code into a service
(Service_Start)
Too if i put into Service_Start i must delete the condition "If FirstTime Then"
So it's a bug? Or a problem of me? If it's about me what the issue to fix that?
Thanks,
https://www.b4x.com/android/forum/threads/http_get-string.61081/
Okay bro i got it, this code work really fine in Main.
But that don't work if i use same code into a service.
(i put all fines, and put code Activity_Create into Service_Start)
Of course i start the service by put in Main Activity "StartService(MyService)"
Anyone can help me ?
Thanks
B4X:
Sub Globals
Dim hc As HttpClient
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
' Activity.LoadLayout("Layout1")
Msgbox("hello","hello")
If FirstTime Then
hc.Initialize("hc")
End If
Dim req As HttpRequest
req.InitializeGet("http://192.168.41.3/android.php")
hc.Execute(req, 1)
StartService(tt)
End Sub
Sub hc_ResponseSuccess (Response As HttpResponse, TaskId As Int)
Dim resultString As String
resultString = Response.GetString("UTF8")
Msgbox(resultString,"test")
End Sub
Sub hc_ResponseError (Response As HttpResponse, Reason As String, StatusCode As Int, TaskId As Int)
Log("Error connecting: " & Reason & " " & StatusCode)
Msgbox("ERROR","test")
If Response <> Null Then
Log(Response.GetString("UTF8"))
Response.Release
End If
End Sub
This specific code won't work if instead of put in main activity i put Main Activity code into a service
(Service_Start)
Too if i put into Service_Start i must delete the condition "If FirstTime Then"
So it's a bug? Or a problem of me? If it's about me what the issue to fix that?
Thanks,