'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim hc As HttpClient
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
End Sub
Sub Activity_Create(FirstTime As Boolean)
hc.Initialize("hc")
Dim req As HttpRequest
Dim web As String
Dim query As String
query="select firstname , lastname from address"
'query="insert into address (firstname , lastname) values ('aa','bbb')"
web="http://giannimaione.altervista.org/demo.php"
req.InitializePost2(web, query.GetBytes("UTF8"))
hc.Execute(req, 1)
'hc.Execute(req,2)
End Sub
Sub hc_ResponseError (Response As HttpResponse, Reason As String, StatusCode As Int, TaskId As Int)
Msgbox("errore","")
End Sub
Sub hc_ResponseSuccess (Response As HttpResponse, TaskId As Int)
If TaskId=1 Then
Dim res As String
res = Response.GetString("UTF8")
Dim parser As JSONParser
parser.Initialize(res)
Dim countries As List
countries = parser.NextArray 'returns a list with maps
For i = 0 To countries.Size - 1
Dim m As Map
m = countries.Get(i)
'We are using a custom type named TwoLines (declared in Sub Globals).
'It allows us to later get the two values when the user presses on an item.
Dim tl,t2 As String
tl = m.Get("lastname")
t2=m.Get("firstname")
Msgbox(tl,t2)
Next
Response.Release
End If
ExitApplication
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub