I have set up the PreferencesActivity in my app and included the ability to change app colors. To get the change to take effect though I seem to have to close the app and reopen it though.
To try to fix this I set up a check on the return to the Main activity, as shown here:
B4X:
Sub Activity_Resume
'If coming from the preferences activity, restart. This is turned on in the preferences screen.
If PreferencesOpened Then
Activity.Finish
StartActivity(Me)
PreferencesOpened = False
End If
End Sub
This doesn't seem to work though, the colors remain unchanged. Is there a way to restart the app programmatically that I should be using instead of this?
Ahh, nevermind. Thanks for taking a look, but it turns out I was failing to reset my color variables in the restart process, I'm all fixed now. Sorry to waste your time on this one.
Sub Globals
Dim t As Timer
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
'Activity.LoadLayout("Layout1")
t.Initialize("timer",1000)
t.Enabled = True
End Sub
Sub timer_tick
Dim col As Int
col = Colors.RGB(Rnd(1, 255),Rnd(1, 255),Rnd(1, 255))
Activity.Color = col
End Sub