'Main Activity
#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
Dim users="users" As String
Dim name As String
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
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
Sub Button1_Click
execute("SELECT id,username,email FROM users WHERE username='John'", users)
End Sub
Sub execute(Query As String, JobName As String)
Dim job As HttpJob
job.Initialize(JobName, Me)
job.PostString("http://www.xxxxx.com/xxxx.php", Query)
End Sub
Sub jobdone (job As HttpJob)
If job.Success Then
Dim ty As String, action As String
ty = job.GetString
Dim parser As JSONParser
parser.Initialize(ty)
Select job.JobName
Case users
Dim countrie As List
countrie = parser.NextArray
For i = 0 To countrie.Size - 1
Dim m As Map
m = countrie.Get(i)
name=m.Get("username")
StartActivity(account)
Next
End Select
End If
End Sub
'Account Activity
#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.
Dim users="users" As String
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.
Dim label1 As Label
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("account")
execute("SELECT id,username,email FROM users WHERE username='"&Main.name&"'", users)
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub execute(Query As String, JobName As String)
Dim job As HttpJob
job.Initialize(JobName, Me)
job.PostString("http://www.xxxxx.com/xxxx.php", Query)
End Sub
Sub jobdone (job As HttpJob)
If job.Success Then
Dim ty As String, action As String
ty = job.GetString
Dim parser As JSONParser
parser.Initialize(ty)
Select job.JobName
Case users
Dim countrie As List
countrie = parser.NextArray
For i = 0 To countrie.Size - 1
Dim m As Map
m = countrie.Get(i)
label1.Text=m.Get("username")
Next
End Select
End If
End Sub