Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("l1")
If FirstTime Then
Dim post As HttpRequest
hc.Initialize("hc")
post.InitializeGet("http://192.168.0.10/testandroid/where.php")
hc.Execute(post, 1)
'It will returns : [{"ID":"21","username":"tedy","password":"888"},{"ID":"23","username":"tom","password":"cat"},{"ID":"22","username":"bunny","password":"carrot"}]
End If
End Sub
Sub hc_ResponseSuccess (Response As HttpResponse, TaskId As Int)
If TaskId = 1 Then
Dim JSON As JSONParser
Dim L1 As List
Dim Result, ReturnString As String
Dim i As Int
Dim M1 As Map
Result = Response.GetString("UTF8")
Label1.Text = Result
JSON.Initialize(Result)
L1 = JSON.NextArray
For i = 0 To L1.Size - 1
M1 = L1.Get(i)
ReturnString = ReturnString & M1.Get("ID") & " : " & M1.Get("username") & " : " & M1.Get("password") & CRLF
Next
Label1.Text = ReturnString
End If
End Sub