Android Question B4XPages.GlobalContext

Erel

B4X founder
Staff member
Licensed User
Longtime User
It is shortly explained here: https://www.b4x.com/android/forum/t...framework-for-managing-multiple-pages.118901/
It is a simple placeholder. You can store whatever you like there.

The use case is with cross platform apps that can start in the background. For example after they receive a push notification. In that case B4XPages will not be initialized but B4XPages.GlobalContext will still be available (if assigned properly when the app starts, in the starter service in B4A).

B4X:
Sub Message_Received
 Starter.SQL.DoSomething 'not cross platform
 Dim sql As SQL = B4XPages.GlobalContext 'cross platform
 sql.DoSomething
 
Upvote 0

PhilipBrown

Active Member
Licensed User
Longtime User
The last paragraph of post#1 of that link makes mention of it.
In fact that page talks about B4XPages.B4XGlobalContext not B4XPages.GlobalContext.
I note also it talks about initializing it in Service_Create of the starter service, but in fact B4XPages.GlobalContext can hold standard variables with being initialized.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
In fact that page talks about B4XPages.B4XGlobalContext not B4XPages.GlobalContext.
Fixed.

I note also it talks about initializing it in Service_Create of the starter service, but in fact B4XPages.GlobalContext can hold standard variables with being initialized.
That's true. It can hold whatever you like. It does make sense to initialize that object in Service_Create of the starter service. This way it will be available in all cases.
 
Upvote 0
Top