1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Donation with Paypal!!!

    Go to your paypal account and send directly donation to [email protected]

    1 month - 10 $ - Standart VIP

    6 months - 20 $- Standart VIP

    1 year - 30 $- Standart VIP

    2 years - 50 $- Standart VIP

    Gold member for life - 150 $- Standart VIP

    High Vip (Standart VIP include) group please send PM or email to [email protected] for info

    After Donation please send email to [email protected]

  3. Donation Ways 2020


    Paysend
  4. Telegram

  5. Delphifan Magazine
Dismiss Notice

Donation with Paypal!!!

Go to your paypal account and send directly donation to [email protected]

1 month - 10 $ - Standart VIP

6 months - 20 $- Standart VIP

1 year - 30 $- Standart VIP

2 years - 50 $- Standart VIP

Gold member for life - 150 $- Standart VIP

High Vip (Standart VIP include) group please send PM or email to [email protected] for info

After Donation please send email to [email protected]

Dismiss Notice
For open hidden message no need write thanks, thank etc. Enough is click to like button on right side of thread.

Setting Android Settings for XE5

Discussion in 'Delphi Android And IOS' started by AdminDF, Mar 5, 2014.

  1. AdminDF
    Online

    AdminDFAdminDF is a Verified Member Delphifan Staff Member DF Staff

    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:

    Code:
    Androidapi.JNI.Provider, // JSettings_SystemClass
    FMX.Helpers.Android; // SharedActivityContext
    Here is the code to read and set the Screen Off Timeout:

    Code:
    function GetScreenOffTimeout: Integer;
    begin
      Result := TJSettings_System.JavaClass.getInt(
        SharedActivityContext.getContentResolver,
        TJSettings_System.JavaClass.SCREEN_OFF_TIMEOUT,
        15000);  // 15 seconds is default is not found
    end;
     
    function SetScreenOffTimeout(ATimeOut: Integer): Boolean;
    begin
      Result := TJSettings_System.JavaClass.putInt(
        SharedActivityContext.getContentResolver,
        TJSettings_System.JavaClass.SCREEN_OFF_TIMEOUT,
        ATimeOut);
    end;

    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.
     
  2. joe.belladonna
    Offline

    joe.belladonna DF Junior

Share This Page