Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("frmSetup")
DownloadRates("https://api.apilayer.com/fixer/latest?apikey=I5prDI8J--------------8Q2i32")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub DownloadRates(Link As String)
Dim job As HttpJob
job.Initialize("", Me)
job.Download(Link)
Wait For (job) JobDone(job As HttpJob)
If job.Success Then
Log(job.GetString)
ToastMessageShow(job.GetString,True)
Dim parser As JSONParser
parser.Initialize(job.GetString)
Dim root As Map = parser.NextObject
Dim date As String = root.Get("date")
Dim rates As Map = root.Get("rates")
Dim SGD As Double = rates.Get("SGD")
Dim MYR As Double = rates.Get("MYR")
Dim GBP As Double = rates.Get("GBP")
Dim AUD As String =root.Get("base")
Log($"The ${AUD} is worth ${SGD} Singapore Dollar on ${date}"$)
Else
Log("Error: " & job.ErrorMessage)
ToastMessageShow("Error: " & job.ErrorMessage, True)
End If
job.Release
End Sub