1

I want change the system brightness using my application. But as soon as i come out of that app. Brightness is again resetted to default value. What shud i do in order to make permanent change to brightness setting? I have tried few ways but all off them only work till my app is not closed.

1 Answers1

0

This code is complite work for change brigtness of android deveice.

Settings.System.putInt(this.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS, 20);

    WindowManager.LayoutParams lp = getWindow().getAttributes();
    lp.screenBrightness =0.2f;// 100 / 100.0f;
    getWindow().setAttributes(lp);

    startActivity(new Intent(this,RefreshScreen.class));

Also give below permission to manifest file

<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
Arvind Kanjariya
  • 2,089
  • 1
  • 18
  • 23