Hi Everyone,
It took me a while to figure it out, but I was having trouble trying to understand how to use the HttpUtils to download several web pages from dictionary.com so I can use that information in my app. Since I figured it out, I'm reposting my message in hopes that other will benefit from what I found of the wonderful HttpUtils. The code included here will download dictionary.com with the results of a query for "this is a test" so an app can use the returned information from dictionary.com
It took me a while to figure it out, but I was having trouble trying to understand how to use the HttpUtils to download several web pages from dictionary.com so I can use that information in my app. Since I figured it out, I'm reposting my message in hopes that other will benefit from what I found of the wonderful HttpUtils. The code included here will download dictionary.com with the results of a query for "this is a test" so an app can use the returned information from dictionary.com
B4X:
'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
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 b4a As String
Dim strDownloadList As List
End Sub
Sub Activity_Create(FirstTime As Boolean)
b4a = "http://dictionary.reference.com/browse/"
strDownloadList.Initialize
strDownloadList.Add(b4a & "this")
strDownloadList.Add(b4a & "is")
strDownloadList.Add(b4a & "a")
strDownloadList.Add(b4a & "test")
HttpUtils.CallbackActivity = "Main" 'Current activity name.
HttpUtils.CallbackJobDoneSub = "JobDone"
HttpUtils.CallbackUrlDoneSub = "UrlDone"
HttpUtils.DownloadList("JobDone", strDownloadList)
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub JobDone (Job As String)
ToastMessageShow("Processing all done.", False)
End Sub
Sub UrlDone(Url)
ToastMessageShow("Processing URL: " & Url, False)
If HttpUtils.IsSuccess(Url) Then
s = HttpUtils.GetString(Url)
ToastMessageShow(s,True)
End If
End Sub
Last edited: