Hello!
Assuming that we should not use starter service when implementing B4XPages in case we think cross platform, I will use the following Erel's answer to a previous post of mine and I will ask where to declare the GlobalContext (Maybe at MainPage or Main Activity?):
Starter service:
B4X:
Sub Service_Create
Dim AppGlobals As clsGlobals
AppGlobals.Initialize
B4XPages.GlobalContext = AppGlobals
End Sub
B4XPages.GlobalContext is only useful in cases where you want to do something in the background and cannot assume that the pages were created.
For example, when receiving push notifications (though cross platform is less relevant in this case).
I suppose he wants declare and initialize global variables.
No need a class, for this, just create a code module and a "Sub Init" in it (call modGlobals.Init from sub Initialize of B4XMainPage).
This code module might be shared between platforms ("Add module to parent folder") or not (used by B4A only).
I suppose he wants declare and initialize global variables.
No need a class, for this, just create a code module and a "Sub Init" in it (call modGlobals.Init from sub Initialize of B4XMainPage).
This code module might be shared between platforms ("Add module to parent folder") or not (used by B4A only).
Hello Erel!
Thank you for your response!
If I need to use FusedLocationProvider and I don't use the starter service, how it's better to implement it? Inside another service, in a class or just into MainPage? Note that only MainPage needs to use it in my case!
Hello!
Assuming that we should not use starter service when implementing B4XPages in case we think cross platform, I will use the following Erel's answer to a previous post of mine and I will ask where to declare the GlobalContext (Maybe at MainPage or Main Activity?):
Starter service:
B4X:
Sub Service_Create
Dim AppGlobals As clsGlobals
AppGlobals.Initialize
B4XPages.GlobalContext = AppGlobals
End Sub
I also used the starter class before I turned over to B4XPages. In my fist steps with this I used starter as well until I read erels comments doing so. This forces me to think about a central point in the app code where to put starter/app globals and I decided to do it in the globals section of a modul (modul1) declaring them as public globals. It works very well only different thing is to put the moduls name before the globals name like modul1.globalname.
Yet I am playing around where to put the starters background services and at the moment I think I ll do it also in the modul or in the mainpage. If you have an comment or proposal to solve this please let me now.
@Guenter Becker ... Just for clarification is your project Cross Platform ?
The way I Interpret / understand it .. even if you are using B4XPages in an Non cross platform app (B4A only) it would still be recommended / wise
to use the Starter Service for declaring global objects , background tasks etc. ... as it was before B4XPages.
Thank you that is good to now because my projects are all focused on B4A. Following your statement means for me back to the roots and transfering the code back to the starter.