问题
i work about application how can change android screen brightness, can somme help me by giving some examples of how to doing this.
Thanks :-)
回答1:
This peice of code will set the brightness:
private void setBrightness(int brightness) {
try {
IHardwareService hardware = IHardwareService.Stub.asInterface(
ServiceManager.getService("hardware"));
if (hardware != null)
hardware.setScreenBacklight(brightness);
} catch (RemoteException doe) {
}
}
Do not forget to add to your manifest
<uses-permission android:name="android.permission.HARDWARE_TEST" />
Please check this full example
回答2:
You can use android settings for brightness.
android.provider.Settings.System.putInt(getContentResolver(),
android.provider.Settings.System.SCREEN_BRIGHTNESS,
(int)progress);
for manualy settings which takes(0-255) as progress and
android.provider.Settings.System.putFloat(getContentResolver(),
AppConstant.SCREEN_AUTO_BRIGHTNESS_ADJ, progress);
for automatic settings which takes(-1to 1) as progress
来源:https://stackoverflow.com/questions/8062305/how-change-screen-led-like-cyanogenmod-widgetrenderfx-night-mod