Setting Android Settings

On the Android platform all the system wide settings that are accessible via the Settings app are also accessible to your app. You just need to add the uses permission WRITE_SETTINGS. Here is a simple Delphi XE5 example for changing the screen timeout.

First you need the following in your uses clause:

Androidapi.JNI.Provider, // JSettings_SystemClass
FMX.Helpers.Android; // SharedActivityContext

Here is the code to read and set the Screen Off Timeout:

function GetScreenOffTimeout: Integer;
  Result := TJSettings_System.JavaClass.getInt(
    15000);  // 15 seconds is default is not found

function SetScreenOffTimeout(ATimeOut: Integer): Boolean;
  Result := TJSettings_System.JavaClass.putInt(

In the GetScreenOffTimeout we pass a default value to use if none is found. I passed in 15000, which is 15 seconds, or the smallest value for my phone. The largest value on my phone is 600000, which is 10 minutes. It appears you can set it to any value, even one that the settings app doesn’t explicitly list as an option.

There are lots of other settings available for your adjustment.

This entry was posted in Android and tagged , , . Bookmark the permalink.

12 Responses to Setting Android Settings

  1. Are these settings global, or do the changes you make only apply to your app? Being able to turn off the SCREEN_OFF_TIMEOUT would be very useful for specific apps, but turning it off globally would be a very bad thing.

  2. Jim McKeeth says:

    These are system wide settings. If you want to keep the screen on for your app you could cache the old timeout and then replace it when your app becomes inactive, or use a WakeLock (I’ll blog about that in the future).

  3. Pingback: Configure Android System Settings From Delphi XE5 Firemonkey | Delphi XE5 Firemonkey, Delphi Android, Delphi IOS

  4. Diego Sandoval Ricci says:

    Hi, i need acces to android WiFi settings or enabled the WiFi on start aaplication created in Delphi xe5. Thanks!

  5. yuri says:

    Sorry for this question, but what’s is the type of “Result”?

  6. Jim McKeeth says:

    Result is the type of the return value from the function. Integer on the first function and Boolean on the second function.

  7. Pingback: Custom Classes.dex | The Podcast at

  8. woomin Yun says:

    hi i’m from korea (south)

    i don’t speak English, but i can struggle.

    ok.. question.

    I want to change the virtual keyboard type in android and ios.

    example, style, keyboard sound, keyboard background, keyboard touch effect.


    and I’ll return the favour some time.

    thank you

  9. Jim McKeeth says:

    Sorry, I haven’t seen how to make those changes to the settings. It might not be possible without Root or Jailbreak.

  10. WadeJ says:

    Having a hard time using this in XE7. Does anyone have the necessary changes.?

  11. WadeJ says:

    You are correct. I was being at bit lazy.

    The includes needed in XE7 are




Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.