Android Question Initialize B4XDialog - FirstTime

lip

Active Member
Licensed User
Longtime User
Context: My project has several activity modules and services. I use Starter service for all Process_Globals that are shared between Activties. I am not using Pages.

The issue I am addressing is occasional lockups (Object Not Initialised) when I pick the tablet up having not touched it for a while (ie half an hour or so). I've not managed to catch it in Debug mode so don't know what is 'not initialised'.

In each Activity module I declare in Globals:

Globals:
    Private Dialog As B4XDialog
    Private XUI As XUI

I initialize B4XDialog in Activity_Create

Activity_Create:
Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("SplashPage")
    If FirstTime Then
        Dialog.Initialize (Activity)

My question is: Should I move Dialog.Initialise (Activity) outside of the FirstTime condition?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
My question is: Should I move Dialog.Initialise (Activity) outside of the FirstTime condition?
Yes.

Globals are recreated when the activity is recreated, so the FirstTime check will cause it to crash.

In the long run you should switch to B4XPages. It solves all these issues and many more.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…