Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting the current screen brightness

Tags:

android

I want to get the real brightness value from the background. I have tried several ways:

1.

    curBrightnessValue =android.provider.Settings.System.getInt(
                getContext().getContentResolver(),
                android.provider.Settings.System.SCREEN_BRIGHTNESS);

But if the screen brightness is on Auto mode the value remain constant.

  1. Reading the sys/class/backlight/brightness/

    This is a good way but I want a way without reading a file.

like image 340
Simon Dzn Avatar asked Oct 11 '15 09:10

Simon Dzn


People also ask

How do I get my screen to brighten?

To change the brightness on an external monitor, use the buttons on it. The Brightness slider appears in action center in Windows 10, version 1903. To find the brightness slider in earlier versions of Windows 10, select Settings > System > Display, and then move the Change brightness slider to adjust the brightness.

Why is my screen so dark?

📲 On Android: Settings > Display > Tap the slider next to Adaptive brightness and switch it to the off position. Then, adjust the brightness bar until you've reached your desired level of brightness. Assuming your display isn't damaged, the most common culprit for a consistently darkened screen is power-saving mode.

How do I adjust screen brightness in Windows 11?

Method 4: Using the Settings app You can also adjust your brightness in Windows 11 using the settings app. Follow the guide below to help you along with the process. Press Windows + i and click Display. Now adjust the slider for Brightness under Brightness & color.


2 Answers

Use the following code to get the brightness of the background (This will also allow you to change the value of brightness if you wish to):

Settings.System.putInt(
    cResolver,
    Settings.System.SCREEN_BRIGHTNESS_MODE,
    Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL);
brightness =
    Settings.System.getInt(
        cResolver,
        Settings.System.SCREEN_BRIGHTNESS);  
System.out.println("Current Brightness level " + brightness);
like image 69
Harshad Naik Avatar answered Oct 23 '22 05:10

Harshad Naik


To my knowledge, it cannot be done any other way in Auto mode. See this answer.

like image 43
solarbabies Avatar answered Oct 23 '22 04:10

solarbabies