Android Question app quit but globals are still loaded

MarcRB

Active Member
Licensed User
Longtime User
Hi,

If I quit my app by this code:
B4X:
Sub btnMenuQuit_Click
    Dim Answ As Int
    Answ = Msgbox2("Are you sure to quit '" & AppUtils.cstAppName & "'?" ,AppUtils.cstAppName,"Yes","","No",Null)
    If Answ = DialogResponse.positive Then
        Activity.finish
    End If
End Sub
Then the app is quited. It is no longer in task manager. Perfect, but....
When I restart the app, the global variable that contains the id of the last datarow is still filled with the number of the previous time i used the app.

So it looks quiting the app will not reset that global var data.
Sure I can set the var to nil or zero at start, but i'm searching for the reason why the data is hold while the app isn't runing.

The position where the global var is located is AppUtils. This is a code module without any layout.
Do I need to close that module?

Best regards,
Marc
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Process global variables are tied to the process. They will remain in memory until Android kills the process.

If you want to reset your program to a specific state then you need to manually reset their values. You can also call ExitApplication to kill the process. However it may cause unwanted side effects.
 
Upvote 0

MarcRB

Active Member
Licensed User
Longtime User
Process global variables are tied to the process. They will remain in memory until Android kills the process.
Is closing all activity's not closing the process?
 
Upvote 0
Top