user820688
user820688

Reputation: 719

how change screen led like Cyanogenmod widgetrenderFx night mod

i work about application how can change android screen brightness, can somme help me by giving some examples of how to doing this.

Thanks :-)

Upvotes: 2

Views: 1382

Answers (2)

Sherif elKhatib
Sherif elKhatib

Reputation: 45942

This peice of code will set the brightness:

private void setBrightness(int brightness) {
    try {
        IHardwareService hardware = IHardwareService.Stub.asInterface(
            ServiceManager.getService("hardware"));
        if (hardware != null)
            hardware.setScreenBacklight(brightness);
        } catch (RemoteException doe) {          
    }        
}

Do not forget to add to your manifest

<uses-permission android:name="android.permission.HARDWARE_TEST" />

Please check this full example

Upvotes: 0

user3207655
user3207655

Reputation: 188

You can use android settings for brightness.

 android.provider.Settings.System.putInt(getContentResolver(),
                android.provider.Settings.System.SCREEN_BRIGHTNESS,
                (int)progress);

for manualy settings which takes(0-255) as progress and

android.provider.Settings.System.putFloat(getContentResolver(),
                AppConstant.SCREEN_AUTO_BRIGHTNESS_ADJ, progress);

for automatic settings which takes(-1to 1) as progress

Upvotes: 0

Related Questions