Android Question B4A StateManager Help

mmieher

Active Member
Licensed User
Longtime User
Dealing with changing orientation for the first time. Not working for me. Have been studying the tutorial. In the sample code:
B4X:
Sub Activity_Pause (UserClosed As Boolean)
    If UserClosed Then
        StateManager.ResetState("Main")
    Else
        StateManager.SaveState(Activity, "Main")
    End If
    StateManager.SaveSettings
End Sub

StateManager.SaveSettings never does anything because settings.IsInitialized is always false. I cannot find anything in the Main module example that would ever initialize settings.

Probably missing something simple.
 

DonManfred

Expert
Licensed User
Longtime User
StateManager.SaveSettings never does anything because settings.IsInitialized is always false. I cannot find anything in the Main module example that would ever initialize settings.
check the modulecode... There is no initialize method (not needed).
 
Upvote 0

mmieher

Active Member
Licensed User
Longtime User
check the modulecode... There is no initialize method (not needed).

So how does this from the modulecode ever do anything in the IF block:
B4X:
'Stored the settings in a file
Public Sub SaveSettings
   
    If settings.IsInitialized Then
       
        Log("SaveSettings")
        For i = 0 To settings.Size - 1
            Log(settings.GetKeyAt(i) & " " & settings.GetValueAt(i))
        Next
       
        File.WriteMap(File.DirInternal, settingsFileName, settings)
    End If
   
End Sub
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…