Android Tutorial Changing the theme at runtime

Using the hooks feature it is possible to change the Activity theme at runtime.

The theme is set before the activity is actually shown. This means that in order to change the theme we need to destroy the activity and start it again. You can use StateManager to save the activity state.

The hook code is:
#if java
public void _onCreate() {
   if (_theme_value != 0)
#end if
There must be a process global int variable named Theme_Value. Note that the underscore is important. It prevents the obfuscator from changing the variable name which will cause the inline Java code to break.


Example updated and the selected theme value is stored in a file. The theme is set when the app starts.


    8.5 KB · Views: 1,537
Last edited:

Similar Threads