android 获取和设置屏幕亮度
16lz
2022-04-22
android 获取和设置屏幕亮度
# 获取屏幕亮度
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 app 获取paypal PaymentDetails
- android 屏幕方向总结
- Android文件夹大小
- 获取Android(安卓)Device的信息
- android 获取通讯模块制式类型
- Android中获取正在运行的服务-------ActivityManager.RunningSer
- android gps经纬度实时更新,获取卫星数量
- android 获取手机的各种状态
- Android中如何获取应用版本号