My app saves the user original brightness with:
originalBrightness = Settings.System.SCREEN_BRIGHTNESS;
and then changes it while the program running.
originalBrightness is private global string. Now what I am trying to do is when the user clicks on "Home" or when the app paused the original screen is need to be set again, I have tried to do this like this but the app crushes:
public void onPause() {
super.onPause();
int brightness = Integer.getInteger(originalBrightness);
setBrightness(brightness);
}
private void setBrightness(int brightness) {
WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
layoutParams.screenBrightness = brightness / 100.0f;
getWindow().setAttributes(layoutParams);
}
Is there away to male it work? Thanks