I'm using the following to set the system auto brightness mode and level:
android.provider.Settings.System.putInt(y.getContentResolver(),Settings.System.SCREEN_BRIGHTNESS_MODE, 0);
android.provider.Settings.System.putInt(y.getContentResolver(),Settings.System.SCREEN_BRIGHTNESS, y.brightness1);
I can change auto-brighess on and off, and set different levels. The settings seem to be applied properly -- I can go to into Settings --> Display --> Brightness, and whanever setting I set is actually shown correctly. However, the actual screen isn't changing its brightness. If i just tap on the slider in Display Settings, then everything gets applied.
I shoudl mention that I'm running an app withat a main activity, and these settings are getting applied in the BroadcastReceiver. I did try to create a dummy activity and tested the stuff there, but got the same results.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…