Android Question [B4XPages] Need clarification about workflow

Cableguy

Expert
Licensed User
Longtime User
Hi Guys and Girls

I have started a few weeks ago, my first serious B4XPages application...

Since I am still in my ascending learning curve, I am learning as I go... And although I am making steady progress, I can't stop thinking I am doing something wrong right from the start...

My implementation goes as this:

In Page_Created I load my Layout and do my user Auth

Then I do most my coding in other subs that relate (one way or another) to Page_Created...

My Page_Appear is completly blank.

However, when I laucnch my app, I get ...

B4X:
** Activity (main) Create, isFirst = true **
Main B4XPage Initialization
*** mainpage: B4XPage_Created
Main B4XPage Layout Loading
FireBase Authoring Initialization
Paulo Gomes is Logged In
User has Logged In Before, we get values from KVS
LastKnownLatitude : 44.9108567
LastKnownLongitude : -0.6833079
Zooming to Last Known Position!
*** mainpage: B4XPage_Appear
** Activity (main) Resume **
onAuthStateChanged: com.google.firebase.auth.internal.zzn@af1d6eb
Paulo Gomes is Logged In
User has Logged In Before, we get values from KVS
LastKnownLatitude : 44.9108567
LastKnownLongitude : -0.6833079
Zooming to Last Known Position!
*** mainpage: B4XPage_PermissionResult [mainpage]
Getting current Location
*** mainpage: B4XPage_PermissionResult [mainpage]
Getting current Location
*** mainpage: B4XPage_PermissionResult [mainpage]
Getting current Location
*** mainpage: B4XPage_PermissionResult [mainpage]
** Activity (main) Pause event (activity is not paused). **
*** mainpage: B4XPage_Disappear [mainpage]
** Service (starter) Destroy (ignored)**

As you can see, After loading Layout, I get the same Logs before Page_Appear, which is normal as my code is to run before page_appear, BUT I also get most of then AFTER page Appear.... So, this means my code Is running Twice!

I fear that as my app will get more and more features, this double run will eventually impact performance...

I need some sort of visual representation (like a flow chart) of how B4XPages work so that I can better implement my code.

Anyone?
 

Cableguy

Expert
Licensed User
Longtime User
I do, but they shouldn't matter as the flow is supposed to wait for completion and not to rerun code before the wait for statement...
 
Upvote 0

Andrew (Digitwell)

Well-Known Member
Licensed User
Longtime User
Not quite.
The flow of control in the current sub is preserved by wait for, however other messages in the message queue may run. which is what you want as this allows the UI to be fluid.

Can you post some code. It looks like line 13 is causing the login to be re-run.
 
Upvote 0

Hamied Abou Hulaikah

Well-Known Member
Licensed User
Longtime User
B4XPages Workflow:
One of the important thing about B4XPages this scenario:
If you created 10 pages, you called them once for every page, then they will be stacked like playing-card.
So they will be available through your app life cycle "not recreated nor destroyed",if you want to show any page you just call it to TOP, others will be stacked behind it.
So there is no create or resume events in B4Xpages.
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
B4XPages Workflow:
One of the important thing about B4XPages this scenario:
If you created 10 pages, you called them once for every page, then they will be stacked like playing-card.
So they will be available through your app life cycle "not recreated nor destroyed",if you want to show any page you just call it to TOP, others will be stacked behind it.
So there is no create or resume events in B4Xpages.
Yes, this much I already know, that's why it puzzles me that some of my code is being re-run after page appear.

Not quite.
The flow of control in the current sub is preserved by wait for, however other messages in the message queue may run. which is what you want as this allows the UI to be fluid.

Can you post some code. It looks like line 13 is causing the login to be re-run.
I will try to streamline my code, simplifying the flow as much as possible... I will comeback to this...
 
Upvote 0

Hamied Abou Hulaikah

Well-Known Member
Licensed User
Longtime User
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
Can you post some code. It looks like line 13 is causing the login to be re-run.

You were right!
Initializing Firebase Authoring MAY fire the Signed_in event if there is already an user!
And since I was also calling the signed_in event a few lines after it, i was getting double logs!
 
Upvote 0
Top