Android Question Drawing to screen from Code Module

Arf

Well-Known Member
Licensed User
Longtime User
I'm trying to inform the user of progress of my database upgrade.
In my main activity, I load my usual layout before calling DDB.Init, which is in a code module.
If a DDB needs converting, it attempts to call a Sub in Main, which loads up a panel to cover the usual main screen, and writes text to a label, informing the user of update progess.

However, when I call the Main functions to update the label, these functions never seem to get hit.

I have just realised that the problem must be that the DDB conversion will be occurring before I return to main's Activity_Create..

B4X:
Sub Activity_Create(FirstTime As Boolean)
    If FirstTime Then
        Global.selectedPatient.Initialize
        StartService(Unit_Comms)
    End If
    Activity.LoadLayout("MenuL")
    If FirstTime Then
        DDB.InitDdb 'conversion happens here if it is required
    End If   
End Sub

I'm trying to figure out a way round this, so far I can only think to trigger the DDB.Init from a timer, but then I thought maybe CallSubDelayed may offer a way out. Would doing:
B4X:
If FirstTime Then
        CallSubDelayed(DDB, "InitDdb")
    End If

be of any help or am I barking up the wrong tree?
 

DonManfred

Expert
Licensed User
Longtime User
Methods from a codemodule does not have an activity.
So from you main activity you just can call the sub in your code module.

Bu if you then want to update your activity you need to use callsubdelayed (or callsub if the activity is already in foreground) to start a method in your activity which then updates the ui

Dont ask for an sample. Use the forumsearch
 
Upvote 0
Top