0

I want current brightness level after setting brightness auto mode. I changed screen brightness, but did not receive the changed brightness level value.

I use Async callable for receive changed brightness level in completed block, but not changed brightness level, exactly screen brightness is changed to auto level.

// Auto mode Setting
Settings.System.putInt(getContentResolver(), Settings.System.SCREEN_BRIGHTNESS_MODE, Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC);

// receive changed brightness level
int level = Settings.System.getInt(getContentResolver(), Settings.System.SCREEN_BRIGHTNESS, default);

First, I set write permission, and I tried Async, RxJava, Coroutine, normal thread runnable in MainUIThread, but I did not receive changed brightness level.

I expect to receive the changed brightness level after setting auto mode brightness.

Halil Ozel
  • 2,482
  • 3
  • 17
  • 32
neander
  • 11
  • 1
  • 1
    Does this answer your question? [Change the System Brightness Programmatically](https://stackoverflow.com/questions/18312609/change-the-system-brightness-programmatically) – Maveňツ Mar 03 '23 at 07:42

1 Answers1

0

This problem Solution

first, you get variable current brightness level int currentLevel = Settings.System.getInt(..., SCREEN_BRIGHTNESS);

sencond, setting bright automode Settings.System.putInt(..., SCREEN_BRIGHTNESS_MODE, SCREEN_BRIGHTNESS_AUTOMATIC);

third, compare to currentLevel and bright level after setting automatic thread sleep 200 ~ 500 possible compare but if same values, count 5 ~ 10

Thread.sleep(500); progressBar.setProgress(Settings.System.getInt(..., SCREEN_BRIGHTNESS));

neander
  • 11
  • 1