Android Question reading android system settings ?

aeropic

Active Member
Licensed User
Longtime User
Hi all,

I'm very new to B4A and this forum, please forgive me if my questions are not really accurate.

I'm trying to develop a kind of "don't lock screen" widget that will turn ON the screen for a very short period just before the lock-screen time out triggers and force the phone to sleep.

The first proto is working fine but I have to set the delay after screen off manually and to make it more user friendly, I would need to read from an internal system variable the setting value of lock-screen time out. (there is a screen_off time out, then a lock-screen time out. I need to read the second one !!!)

I've searched everywhere on the forum and could not find a way to do this.

Thanks for your advices !
Alain
 
Try: Phone.GetSettings("screen_off_timeout")

Thank you Erel for your fast answer.
I tried it. It works fine to get the screen_off time out. It returns indeed the number of ticks for instance if accessibility/delay to turn off screen is set to 2 min, I get 120000...

But I need to read the other time-out (accessibility/automatically lock (screen will be locked within 3 minutes after its automatic desactivation) <== translation from french sorry !

In fact, on my galaxy S3, screen_off_timeout + lock_screen_timeout <= 5 minutes. if I set the screen_off to 2 minutes, I can only set Lock_screen to maximum 3 minutes.
It is this value of 3 minutes I would want to programatically read...
 
Upvote 0
Humm, I'm afraid you're right Erel, I don't see any setting looking like: lock_screen or sleep something ...

but meanwhile, I gave a try to the administrator library...
This is great: I managed to have access to admin priviledge and, as a test, succeeded to lock the screen.

I've seen there is a way to program the MaximumTimeToLock, but this constant is write only in the admin library...
However, I found this on https://gitorious.org/android-enabl...droid/app/admin/DevicePolicyManager.java#L488

It looks like a new member could be added in the library to getMaximumTimeToLock without modifying it ... but this is far from my skills ;)

  • public void setMaximumTimeToLock(ComponentName admin, long timeMs) {
  • if (mService != null) {
  • try {
  • mService.setMaximumTimeToLock(admin, timeMs);
  • } catch (RemoteException e) {
  • Log.w(TAG, "Failed talking with device policy service", e);
  • }
  • }
  • }
  • /**
  • * Retrieve the current maximum time to unlock for all admins
  • * or a particular one.
  • * @param admin The name of the admin component to check, or null to aggregate
  • * all admins.
  • */
  • public long getMaximumTimeToLock(ComponentName admin) {
  • if (mService != null) {
  • try {
  • return mService.getMaximumTimeToLock(admin);
  • } catch (RemoteException e) {
  • Log.w(TAG, "Failed talking with device policy service", e);
  • }
  • }
  • return 0;
  • }

 
Last edited:
Upvote 0
Hi Erel,
Associated with screen off time out, I would get the range of values from 0 to maxtimetolock - screenOff...

But nevertheless, You're right it does not return the time to lock ! As the user is allowed to modify it, it should be stored somewhere, should'nt it ?
 
Upvote 0
Back
Top