0

How can I disable the development setting which prevents screen from turning off when plugged in?

Basically I want to detect user inactivity on an Android device by detecting when screen goes off, but if this setting is enabled this will never happen. From what I found, WRITE_SECURE_SETTINGS permission should be used (rooting device/using private APIs is not a problem).

Tomik
  • 23,857
  • 8
  • 121
  • 100
Rui
  • 5,900
  • 10
  • 38
  • 56

1 Answers1

0

You could try something like this:

Settings.System.putInt(getContentResolver(), Settings.System.STAY_ON_WHILE_PLUGGED_IN, 0);
user1256821
  • 1,158
  • 3
  • 15
  • 35