Android Question PUBLIC VAR in activity o PUBLIC in modules

netsistemas

Active Member
Licensed User
Longtime User
I have a fairly large app (B4A no B4APage).

The problem is that I get the feeling that when the phone goes into inactivity, the activity variables are lost, both in the activity itself (understandable), and the assignments I have made to pass the value to another activity.
That said, the question is:
Is it correct to use a public variable in an activity (the app is not B4XPAGES, and I cannot transform it) and make assignments of this variable to other activities.

Something like

ACTIVITY1:
B4X:
type DATATYPE(x as string, y as string, etc)
PUBLIC X AS DATATYPE
....


ACTIVITY2.XCOPY = ACTIVITY1.X
startactivity (ACTIVITY2)

Or would it be better to ALWAYS put these variables in a MODULE as public and solve it?

If activity1 is destroyed, do I lose the value in activity2?
and if so, I'm almost sure.
Is the solution to CLONE all the values from one activity to another or perhaps as I said, pass that value to a module as public variables?
 

netsistemas

Active Member
Licensed User
Longtime User
I think one of my doubts(questions) is solved here:


Public variables must be declared in the starter, not in a module. They can disappear if the OS requires it.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…