I am trying to create an app which will set brightness of an android device programmatically. I have manage to change device brightness using the following code:
BackLightValue = (float)arg1/100;
BackLightSetting.setText(String.valueOf(BackLightValue));
WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
layoutParams.screenBrightness = BackLightValue;
getWindow().setAttributes(layoutParams);
I have retrieve current system brightness value using following code:
try {
BackLightValue = android.provider.Settings.System.getInt(getContentResolver(), android.provider.Settings.System.SCREEN_BRIGHTNESS);
} catch(Exception e) {}
Above code should give me current set value for brightness but when I start an app it shows default value at 50%.
What is going wrong?