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

Discussion in 'Android Questions' started by incendio, Mar 24, 2015.

  1. incendio

    incendio Well-Known Member Licensed 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 :
    Code:
    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
    Code:
    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.
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Change:
    LastParams.Initialize
    PrevParams.Initialize

    To:
    Code:
    If FirstTime Then
    LastParams.Initialize
    PrevParams.Initialize
    End If
     
  3. incendio

    incendio Well-Known Member Licensed User

    Ok, thanks, it worked.
     
    Last edited: Mar 24, 2015
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice