private void toggleBrightness() {
WindowManager.LayoutParams lp = getWindow().getAttributes();
int curBrightnessValue;
try {
curBrightnessValue = android.provider.Settings.System.getInt(getContentResolver(), android.provider.Settings.System.SCREEN_BRIGHTNESS);
if (curBrightnessValue == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC) {
Settings.System.putInt(getContentResolver(),
Settings.System.SCREEN_BRIGHTNESS_MODE,
Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL);
}
Utils.Log("curBrightnessValue = " + curBrightnessValue);
if (curBrightnessValue >= 255/2 && curBrightnessValue < 255) {
lp.screenBrightness = 255 / 255.0f;
android.provider.Settings.System.putInt(getContentResolver(), android.provider.Settings.System.SCREEN_BRIGHTNESS, 255);
} else if(curBrightnessValue == 255) {
lp.screenBrightness = 0.1f;
android.provider.Settings.System.putInt(getContentResolver(), android.provider.Settings.System.SCREEN_BRIGHTNESS, 10);
} else if(curBrightnessValue >= 0 && curBrightnessValue <= 255/2) {
lp.screenBrightness = 0.5f;
android.provider.Settings.System.putInt(getContentResolver(), android.provider.Settings.System.SCREEN_BRIGHTNESS, 255/2);
}
} catch (SettingNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return;
}
Utils.Log("lp.screenBrightness = " + lp.screenBrightness + "\n");
getWindow().setAttributes(lp);
// startActivity(new Intent(this, Bright.class));
// Toast.makeText(getBaseContext(), "This should toggle brightness", Toast.LENGTH_SHORT).show();
}
이거 말씀하시는건가요??