I have a widget that changes some system settings, but it will not take right away. It seems like I need to refresh the system settings for it to take. How do you change some system settings from a widget that take instantly?
when my widget is pressed it goes to an activity with a blank background to change the system settings. one of the settings that are changed is the display brightness. this is the code i use to change the display brightness. once i change the settings i call the finish function to exit the activity so i am not stuck there after the settings are changed. One thing i did notice is that if i didnt exit the activity the settings did change, but i was stuck in the activity. its when i added the class.this.finish(); to exit the activity that the settings don't change.
android.provider.Settings.System.putInt(getContentResolver(),android.provider.Settings.System.SCREEN_BRIGHTNESS, brightness); // 0-255
WindowManager.LayoutParams lp = getWindow().getAttributes();
lp.screenBrightness = brightness / 255.0f;
getWindow().setAttributes(lp);