亮度

// 调整屏幕亮度 --> 把亮度调到最高
        WindowManager.LayoutParams lp = getActivity().getWindow().getAttributes();
        lp.screenBrightness = 255f * (1f / 255f);
        getActivity().getWindow().setAttributes(lp);
/**
     * 获取当前系统亮度
     */
    private int getCurrentSystemScreenLight() {
        int brightValue = 160;
        ContentResolver contentResolver = getActivity().getContentResolver();
        try {
            brightValue = Settings.System.getInt(contentResolver, Settings.System.SCREEN_BRIGHTNESS);
        } catch (Settings.SettingNotFoundException e) {
            MyLog.e("获取当前屏幕亮度失败");
        }
        MyLog.d("当前屏幕亮度:" + brightValue);
        return brightValue;
    }
// 屏幕亮度恢复
        WindowManager.LayoutParams lp = getActivity().getWindow().getAttributes();
        lp.screenBrightness = currentScreenLight;
        getActivity().getWindow().setAttributes(lp);

 

posted @ 2018-06-26 10:45  H_bolin  阅读(315)  评论(0编辑  收藏  举报