'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.
hc.Initialize("hc")
Dim WebView1 As WebView
Dim textbox1 As EditText
Dim lv As LayoutValues
lv = GetDeviceLayoutValues
End Sub
Sub Activity_Create(FirstTime As Boolean)
WebView1.Initialize("")
textbox1.Initialize("")
Activity.AddView(WebView1,10dip,10dip,lv.Width-10,(lv.Height/2)-10)
Activity.AddView(textbox1,10dip,lv.Height/2,lv.Width-10,(lv.Height/2)-10)
GetWebPage
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub GetWebPage
Dim req As HttpRequest 'Set up an http request connection
Dim PostUrl As String 'This will hold the url
PostUrl ="http://www.google.com"
req.InitializeGet(PostUrl) 'Initialize the http get request
ProgressDialogShow("Getting Messages...") 'Let The user know what is going on.
hc.Execute(req, 1)
End Sub
Sub hc_ResponseSuccess (Response As HttpResponse, TaskId As Int) 'We got connection and data !!
ProgressDialogHide 'Close the waiting message..
Dim resultString As String
Dim webstring As String
resultString = Response.GetString("UTF8") 'This holds the returned data
webstring = resultString.Replace("Google", "Edward") 'This will change google on the web to edward
textbox1.Text=resultString
WebView1.LoadHtml(webstring )
response.Release
End Sub
Sub hc_ResponseError (Response As HttpResponse, Reason As String, StatusCode As Int, TaskId As Int) 'No connection :-(
Log("Error connecting: " & Reason & " " & StatusCode)
If Response <> Null Then
Log(Response.GetString("UTF8"))
ProgressDialogHide
Response.Release
End If
End Sub