android 获取和设置屏幕亮度
16lz
2022-06-15
# 获取屏幕亮度
public static int getScreenBrightness(Activity activity) {
int value = 0;
ContentResolver cr = activity.getContentResolver();
try {
value = Settings.System.getInt(cr, Settings.System.SCREEN_BRIGHTNESS);
} catch (SettingNotFoundException e) {
}
return value;
}
# 设置屏幕亮度
public static void setScreenBrightness(Activity activity, int value) {
WindowManager.LayoutParams params = activity.getWindow().getAttributes();
params.screenBrightness = value / 255f;
activity.getWindow().setAttributes(params);
}
更多相关文章
- Android中获取正在运行的应用程序-----ActivityManager.RunningA
- android屏幕的那些事之一!
- 【Android优化】去掉屏幕上方应用程序的名称或标题栏
- Android(安卓)自己制作的相册--效果还不错哦
- 理解 Context.getSystemService 原理
- Android用户手势检测
- Android(安卓)飞行模式的设置(打开/关闭飞行模式,获取飞行状态状
- Android中通过按键旋转屏幕
- Android(安卓)L下载