iOS Question [SOLVED] Monitor http requests progress B4XPages Compatible?


Licensed User
Erel shows an interest code to follow the HTTP activity in the app, the link is:
Monitor HTTP Requests

However the code don't work with B4XPages, I put the code in a Utility.bas module, and called it in the 3 pages B4XPages example, in B4XMainPage.bas like this:

Sub ServerSwitcher() As ResumableSub
    Dim j As HttpJob
    Dim Resultado As String
    Dim parser As JSONParser
    'Log("Inicio Main ServerSwitcher")
    j.Download(Main.Servidor & "/version")

I got the run time error: Object was not initialized (UIViewController) in this line of the Monitor code:
Page1.Title = $"$1.2{fraction * 100}%-${url}"$
Looks like Page1 is not defined when B4XPages is running, or maibe I need to send the Page1 as a parameter to the monitor (since is scope of Page1 is in another module)
Last edited:

Semen Matusovskiy

Well-Known Member
Licensed User
You need to add to MonitorProcess a parameter, for example, Sub MonitorProgress (PageName As String)
In Erel's 3 pages example PageName = "MainPage" (for B4XMainPage module), "Page 2" (for B4XPage2) or "Page 3" (for B4XPage3).
After Sub MonitorProgress (PageName As String) add
    Dim App As Application
    Dim Page1 As Page = B4XPages.GetNativeParent (B4XPages.GetPage(PageName))

When you start new download and call MonitorProcess, ensure that previous download was finished. Otherwise calculations will be wrong.
Upvote 0