Android Question Change Colors after PreferencesActivity Change

shaffnert03

Member
Licensed User
Longtime User
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?
 
Last edited:

shaffnert03

Member
Licensed User
Longtime User
I actually am. The code I posted above is in Activity_resume of the Main activity, will correct that in the previous post. Still doesn't seem to work.
 
Upvote 0

shaffnert03

Member
Licensed User
Longtime User
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.
 
Upvote 0

haddad

Member
Licensed User
Longtime User
hi

I want my activity change colors each 1000ms how to make , and sorry for my bed english

thank you for your answers
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
I want my activity change colors each 1000ms
B4X:
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
 
Upvote 0
Top