You can use Android Shared Preferences to remember the selected background color for the application. Therefore, every time you open the application, you can check the value of the general setting and apply the color accordingly.
Use a common base activity class, which all other actions will be received, and in the "OnCreate" and "OnResume" methods write code to read the general preference value and apply the back color. This method, when you open any selected background activity color will be applied.
Try it under the code, it is tested and works.
BaseActivity Class
public class BaseActivity extends ActionBarActivity { private static final String PREFS_NAME="color_settings"; SharedPreferences prefsReader = null; @Override protected void onCreate(Bundle savedInstanceState) {
Action class
public class MainActivity extends BaseActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
Color List Colors.xml
<?xml version="1.0" encoding="utf-8"?> <resources> <item name="blue" type="color">#FF33B5E5</item> <item name="purple" type="color">#FFAA66CC</item> <item name="green" type="color">#FF99CC00</item> <item name="orange" type="color">#FFFFBB33</item> <item name="red" type="color">#FFFF4444</item> <item name="darkblue" type="color">#FF0099CC</item> <item name="darkpurple" type="color">#FF9933CC</item> <item name="darkgreen" type="color">#FF669900</item> <item name="darkorange" type="color">#FFFF8800</item> <item name="darkred" type="color">#FFCC0000</item> </resources>
source share