Android Question [B4xPages] How to always run a procedure when starting the program?

vecino

Well-Known Member
Licensed User
Longtime User
Hi, I need to run something whenever the program starts.
In the "Created" it runs the first time, if I close the program and reopen it, it doesn't run.
In the "Appair" it is not valid because it is executed when the page changes and returns to the first one.
Where do I put it?
It is to ask for a password, show a splash, etc.
In B4XMainPage I can't find the solution.
Do I put the code in the "Activiy Main"?
Thank you.
 

vecino

Well-Known Member
Licensed User
Longtime User
Hello, where is "Initialize"?
loquehay.png
 
Upvote 0

makis_best

Well-Known Member
Licensed User
Longtime User
Don't write code on Main Page, only in B4XMainPage and there use Initialize.
On main page write code only for extreme specific cases.
 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
It also doesn't work in Initialize :/
The first time it does run showsplash and other things.
Then I close, I open ... and it doesn't go through Initialize.
I have put "logs" to follow it and you can see that it does not go through Initialize.

nova.png
 
Upvote 0

makis_best

Well-Known Member
Licensed User
Longtime User
When you say close... you mean that you exit application?
The Logs are set to main or B4XMainPage?

Copy the text of your Log and paste it here using <code> </code>
Don't post it here as picture.
 
Last edited:
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
It is exactly the same case.
When you start the application you must ask for a password (among other things).
If I exit the application and enter again, it does not go through "Create", so it does not ask for the password.

I think Erel is not right in what he says in that other thread (now I will get hits from all sides :D)
In the activities the "Create" is always executed when you start the application, if you exit the application and re-enter then it runs again create (although in that case is not "firstime").
However, with B4Xpages this does not happen, there is no other solution than to use a variable, as discussed in this other thread.

That's the conclusion I've reached after many tests.
Hopefully there is a more appropriate solution.
Thank you.
 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
Yes, but how do you make it always run when you start the application?
Even if you leave the application and return to the moment, always run.
 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
But that's the problem, isn't it?
That "Created" is not executed after leaving the application and entering again, so that other page would not be shown either.
 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
It's the same problem, it doesn't ask for the "login" again because it doesn't go through "Created", except the first time.
:confused::confused::confused:
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Why do you need to login (and show the splash screen) twice?

If the user forces the app to close, or the operating system kills it or when the user turns off the device and turns it back on the next day, the splash screen and login will be displayed.
 
Upvote 0
Top