Android Question How to save variable type map in activity pause?

incendio

Well-Known Member
Licensed User
Longtime User
Hi all,

I have a need to save variable type map on Activity Pause and reuse it on Activity Resume.

I have 2 activities, act1 and act2, act1 call act2 with codes something like this :
B4X:
Dim m As Map
m.Initialize
m.Put("Title1","Sales Report")
m.Put("RptTyp","SalesRpt")
CallSubDelayed2(act2, "ShowReport",m)

And codes on act2, something like these
B4X:
Sub Process_Globals
    Private PrevParams As Map
    Private LastParams As Map
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("Template")
    LastParams.Initialize
    PrevParams.Initialize
End Sub

Sub Activity_Resume
    Log(LastParams.Size)
    Log(PrevParams.Size)
End Sub

Sub Activity_Pause (UserClosed As Boolean)
    PrevParams = LastParams
    Log(LastParams.Size)
End Sub

Sub ShowReport(Params As Map)
    LastParams = Params
End Sub

PrevParams.Size on Activity Resume always show 0, means map variable is not saved.
Can anyone help me how save this variable, also, if possible, not using process global variable?

Thanks in advance.
 
Top