Search code examples
androidscreen-brightness

Android: Set automatic brightness adaptation speed


I would like to modify, how fast the screen brightness is changed by Android, if Automatic brightness is enabled in the Android Settings.

The issue is that it is quite annoying if screen brightness changes rapidly, because if the light sensor is covered accidentally by the user's hand.

It is not an option to disable automatic brightness.

I found this: Change brightness according to surrounding light in android But I would prefer to not hack it manually...

Are there nicer options?


Solution

  • You might want to take a look at these constants

     private static final int BRIGHTNESS_RAMP_RATE_FAST = 200;
     private static final int BRIGHTNESS_RAMP_RATE_SLOW = 40;
    

    and how they're used in DisplayPowerController class which

     Controls the power state of the display. Handles the proximity sensor, light sensor,
     and animations between states including the screen off animation. 
    

    You might also want to take a look at rate parameter of public boolean registerListener (SensorListener listener, int sensors, int rate) as described here

     The rate sensor events are delivered at. This is only a hint to the system. 
     Events may be received faster or slower than the specified rate. 
     Usually events are received faster. The value must be one of SENSOR_DELAY_NORMAL,
     SENSOR_DELAY_UI, SENSOR_DELAY_GAME, or SENSOR_DELAY_FASTEST or, the desired delay
     between events in microseconds. 
     Specifying the delay in microseconds only works from
     Android 2.3 (API level 9) onwards. For earlier releases, you must use one of the 
     SENSOR_DELAY_* constants.