亮度

// 調整屏幕亮度 --> 把亮度調到最高
        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);
相關文章
相關標籤/搜索