Home > Enterprise >  Is it possible to write a script that allows you to change the brightness from the lock-screen?
Is it possible to write a script that allows you to change the brightness from the lock-screen?

Time:06-07

I am looking to write a basic Android script, for when you hold 2-3 seconds on your device's lock-screen, it will set the brightness to 100. Is this possible on most modern Android devices, and what are some tips I can use to achieve this?

I am specifically looking for these features:

  • The ability to set the system's brightness to "x" on the lock-screen
  • The ability to detect if the user has held their finger in a specific spot for "y" amount of time on the lock-screen.

CodePudding user response:

  • setting brightness with Settings.System.SCREEN_BRIGHTNESS is possible when you acquire proper permission (hints: ACTION_MANAGE_WRITE_SETTINGS, Settings.System.canWrite(context)). BUT on lock screen you can show ONLY Notification, which can't have a seekbar/progressbar controlled by user manually (it can only show progress and on newest OS versions can seek playback if your app is handling audio focus and MediaSession). Instead you can introduce some action buttons, e.g. three options: lowest brightness, auto, max brightness
  • this is not possible on lock screen. you could achieve this in whole not-locked system (any app) with AccessibilityService, but it will run only when device is unlocked
  • Related