4

i've already asked this question HERE before but i've been misunderstood. So now i try to be more explicit.

In Android system settings there's an option under Security called "Automatically lock". By default it's set to 5 second. I need to programmatically get that value.

Before you marked my question as duplicated of THIS question but it isn't the same.

To be more clear i put here 2 screenshot:

This is what i need ("Automatically lock"):

What i need "Automatically lock"

This is what

    Settings.System.getInt(getContentResolver(), Settings.System.SCREEN_OFF_TIMEOUT, DELAY); 

returns. ("Sleep")

What you think i need

I hope this is more clear.

Thanks!

Community
  • 1
  • 1
Slv3r
  • 479
  • 1
  • 5
  • 15

3 Answers3

2

Try

Settings.Secure.getLong(getContentResolver(), "lock_screen_lock_after_timeout", 5000);
srzdev
  • 202
  • 1
  • 2
  • 10
2

Thx to srzdev advice i've found out a solution!

    int time = Settings.Secure.getInt(getContentResolver(), "lock_screen_lock_after_timeout", 5000);

I'm not sure if this work on all android version, i've tested it on 4.2 and 4.3 and it works!

Slv3r
  • 479
  • 1
  • 5
  • 15
-1
 private static final int DELAY = 3000;
    int defTimeOut = 0;    

defTimeOut = Settings.System.getInt(getContentResolver(), 
                             Settings.System.SCREEN_OFF_TIMEOUT, DELAY);

            Settings.System.putInt(getContentResolver(), Settings.System.SCREEN_OFF_TIMEOUT, DELAY);
ShutterSoul
  • 2,551
  • 3
  • 23
  • 28