Android Tutorial StateManager - Helps managing Android applications settings and state

Status
Not open for further replies.

padvou

Active Member
Licensed User
Longtime User
I will try and use labels to store values so that when state manager restores them I will re-read them and restore other things, like queries, etc. Unless of course there's some other way.. :sign0104:
I tried to add labels to the statemanager code, but i kept getting an index out of bounds exception.. :BangHead:
Could you help me with this please?
 

padvou

Active Member
Licensed User
Longtime User
StateManager also allows you to store settings. See the tutorial (first post).

I took a look, but i can't seem to get it...
I mean I 'd like to store variables. Is this possible?
Also, when i restore a text value to an autocompleteedittext, it shows the list with the record according to the text restored, exactly as if I typed it and the had to choose it. Any ideas?
 

padvou

Active Member
Licensed User
Longtime User
You can store any value you like with StateManager. See the example.


Do you want to close the drop down list?

Yes please! :sign0188:
About the example... I 'll take another look, but I must be missing something..
 

padvou

Active Member
Licensed User
Longtime User
Could you please help me out as to where exactly this snippet should be placed?

Is it correct this way:
If StateManager.RestoreState(Activity, "OrderEntry", 1) = False Then
'set the default values
'EditText1.Text = "Default text"
'EditText2.Text = "Default text"
Else
Custselector.DismissDropDown
End If
 

padvou

Active Member
Licensed User
Longtime User
Try it. Seems to be correct. Though nothing will happen if you call it in any case.

Seems to work...
Could you also please show me a brief example on how to store variable values?
 

padvou

Active Member
Licensed User
Longtime User
B4X:
StateManager.SetSetting("SomeKey", x)

if i have
Dim CustomerEmail As String

in Globals
will this be: StateManager.SetSetting("CustomerEmail", me@server.local)
or StateManager.SetSetting("me@server.local", CustomerEmail)
Sorry for still not getting it.. :sign0104:
Also, setsetting is for setting the value, right? I must also have a statemanager.getsetting or getsetting2 to restore? What is the difference in getsetting and getsetting2?

OK, I added StateManager.SetSetting("CustomerEmail", CustomerEmail) in the sub that makes this value, and also added CustomerEmail=StateManager.GetSetting("CustomerEmail") in Activity_Create near the end..
Could you please verify this for me?
 
Last edited:

padvou

Active Member
Licensed User
Longtime User
Good morning everyone,
I still can't get statemanager to work...
Values from various controls get mixed up with values of other controls..
It's a total mess!!
Could anyone assist me?
I have uploaded in a zip file the relevant .bas files
I've noticed that a listview returns true in if v is panel
Should this happen? Could it be relevant?
 

Attachments

  • FrameOrders8StateManager.zip
    12.9 KB · Views: 412
Last edited:

padvou

Active Member
Licensed User
Longtime User
Is there a way to clear all data statemanager has saved, when the application exits?
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…