Hi,
I'm having problems getting data from my server, I've following two different approaches posted here but both of them crashes at the same line.
First:
I'm developing for Android 2.3 in mind
I'm testing in a real device (USB) with Android 4.04
The error is "android.os.NetworkOnMainThreadException"
The problematic line is -> Receive = Response.GetString("UTF8")
The code:
I'm guessing if the returned JSON is so big ... It's 76193 chars long...
Thanks for any help
I'm having problems getting data from my server, I've following two different approaches posted here but both of them crashes at the same line.
First:
I'm developing for Android 2.3 in mind
I'm testing in a real device (USB) with Android 4.04
The error is "android.os.NetworkOnMainThreadException"
The problematic line is -> Receive = Response.GetString("UTF8")
The code:
B4X:
Sub Process_Globals
Dim host As HttpClient
Dim Request As HttpRequest
Dim hostAddress As String
Dim Transmit As String
Dim Receive As String
Dim task_Lugares As Int = 1
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
hostAddress = "http://myhost.com/dataGet.php"
Transmit = hostAddress & ""
host.Initialize("host")
End If
Request.InitializeGet(Transmit)
Request.Timeout = 60000
host.Execute(Request, task_Lugares)
ProgressDialogShow("Loading...")
End Sub
Sub host_ResponseSuccess (Response As HttpResponse, TaskId As Int)
ProgressDialogHide
Receive = Response.GetString("UTF8") ' <--- CRAAAASSHHH!!!
Log("Response from server: " & Receive)
End Sub
I'm guessing if the returned JSON is so big ... It's 76193 chars long...
Thanks for any help