0

I would like to read the current setting for 'Battery' -> 'Sleep', ie is it 30 seconds or 5 mins.

Is this possible on Android and is there a Flutter plugin perhaps?

atreeon
  • 21,799
  • 13
  • 85
  • 104
  • You can do it by using [platform channels](https://docs.flutter.dev/development/platform-integration/platform-channels) – HTMHell Apr 07 '23 at 15:11
  • ok, thatnks @HTMHell https://stackoverflow.com/questions/11985251/how-to-access-device-settings-programmatically I think suggests it is possible on the Android side. It says it needs root access for Settings.secure. I wonder if I need root access for Settings.System.SCREEN_OFF_TIMEOUT (I think that is the correct setting). – atreeon Apr 07 '23 at 15:28
  • Actually it says 'Secure system settings, containing system preferences that applications can read but are not allowed to write.' in the documentation under the 'Settings.Secure' class and doesn't say anything like that under the Settings.System class so I assume I could read & write there and just read on the secure class. – atreeon Apr 07 '23 at 15:30
  • https://developer.android.com/reference/android/provider/Settings.System – atreeon Apr 07 '23 at 15:47
  • Writing to any Settings Provider requires the permission WRITE_SYTEM_SETTINGS. Settings.Secure write permission is not granted to third party apps. Only system apps can write to Seetings.Secure. Also, you can read any value from these settings. But you can't write to any of them – Just a Person Apr 07 '23 at 17:11

0 Answers0