#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.
Dim Client As HttpClient
Dim Request As HttpRequest
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.
Private ButtonGet As Button
Private 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("Layout1")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub ButtonGet_Click
Client.Initialize("client")
Request.InitializeGet("http://dummy.restapiexample.com/api/v1/employees")
Client.Execute(Request, 1)
End Sub
'Client -> Response
Public Sub client_ResponseSuccess (Response As HttpResponse, TaskId As Int)
Label1.Text = Response.GetString("UTF8")
Log(Label1.Text)
End Sub
'Client -> Response
Public Sub client_ResponseError (Response As HttpResponse, Reason As String, StatusCode As Int, TaskId As Int)
MsgboxAsync(Reason & CRLF & StatusCode, "Response Error")
End Sub
Sub Response_StreamFinish (Success As Boolean, TaskId As Int)
If Success = False Then
Msgbox(LastException.Message, "Error")
Return
End If
End Sub