how change screen led like Cyanogenmod widgetrenderFx night mod

泄露秘密 提交于 2019-12-11 01:32:29

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!