Android Screen Brightness Set setScreenBrightness(final Activity pActivity, final float pScreenBrightness)

Here you can find the source of setScreenBrightness(final Activity pActivity, final float pScreenBrightness)

Description

set Screen Brightness

Parameter

Parameter Description
pActivity a parameter
pScreenBrightness [0..1]

Declaration

public static void setScreenBrightness(final Activity pActivity,
        final float pScreenBrightness) 

Method Source Code

//package com.java2s;

import android.app.Activity;

import android.view.Window;
import android.view.WindowManager;

public class Main {
    /**//w w w.  j  a va 2 s .  c  o m
     * @param pActivity
     * @param pScreenBrightness [0..1]
     */
    public static void setScreenBrightness(final Activity pActivity,
            final float pScreenBrightness) {
        final Window window = pActivity.getWindow();
        final WindowManager.LayoutParams windowLayoutParams = window
                .getAttributes();
        windowLayoutParams.screenBrightness = pScreenBrightness;
        window.setAttributes(windowLayoutParams);
    }
}