In this post I saw a code to download a quote:
https://www.b4x.com/android/forum/threads/b4x-okhttputils2-with-wait-for.79345/
I have a similar code to download a text and show the text in a label in the main activity.
How I can put this code in a service, call it and show the quote received in a label (LabelQuote) in main activity?
Thanks in advance for any tip.
https://www.b4x.com/android/forum/threads/b4x-okhttputils2-with-wait-for.79345/
B4X:
Sub DownloadQuote
Dim j As HttpJob
j.Initialize("", Me)
j.Download("http://quotesondesign.com/wp-json/posts?filter[orderby]=rand")
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
Dim jp As JSONParser
jp.Initialize(j.GetString)
Dim quotes As List = jp.NextArray
For Each quot As Map In quotes
LabelQuote.Text = quot.Get("title") & CRLF & quot.Get("content")
Next
End If
j.Release
End Sub
How I can put this code in a service, call it and show the quote received in a label (LabelQuote) in main activity?
Thanks in advance for any tip.