Get access to over 100 FireMonkey cross platform samples for Android, IOS, OSX, Windows, and Linux!

AndroidAppmethodCode SnippetDelphiFiremonkey

Configure Android System Settings From Delphi XE5 Firemonkey

| Delphi 11 10 XE8 XE7 XE Seattle Berlin Tokyo Rio Firemonkey Delphi Android Delphi IOS

Delphi XE5 Firemonkey Android System Settings | Delphi 11 10 XE8 XE7 XE Seattle Berlin Tokyo Rio Firemonkey Delphi Android Delphi IOSJim McKeeth from Embarcadero has a blog post up where he shows how to use the Android API with Delphi XE5 Firemonkey to access the system settings of the device. Your app must request permissions from the user in the manifest to access the system settings but once you have that there are a lot of useful settings you can read and write using the android.provider.Settings.System. Some examples of the system settings you can read and write with this API are VIBRATE_ON, VOLUME_ALARM, VOLUME_BLUETOOTH_SCO, VOLUME_MUSIC, VOLUME_NOTIFICATION, VOLUME_RING, VOLUME_SYSTEM, VOLUME_VOICE and a lot more. Jim set up two functions which read and write the SCREEN_OFF_TIMEOUT setting. You should be able to easily customize the two functions to read and write any setting you need. Here is the required Android permission from the manifest:
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
And here is the sample function to set the screen off timeout. It demonstrates how easy to it to send an integer from Delphi XE5 Firemonkey through the JNI interface to the Android SDK.
function SetScreenOffTimeout(ATimeOut: Integer): Boolean;
begin
Result := TJSettings_System.JavaClass.putInt(
SharedActivityContext.getContentResolver,
TJSettings_System.JavaClass.SCREEN_OFF_TIMEOUT,
ATimeOut);
end;

Head over and read Jim’s full blog post about the system settings API.

Have Delphi Firemonkey questions? Ask and get answers on StackOverflow.

Related posts
DelphiDemoFiremonkeyLinuxOSXShowcaseWindows

AutoBlogAI: FireMonkey Client To Leverage LLMs And Generative AI For Blogging

DelphiFiremonkeyShowcaseUtilityWindows

Unleashing Creativity With Song Writer AI: A Deep Dive

DelphiFiremonkeyShowcaseWindows

How To Build Stable Diffusion Text To Image Prompts

AndroidC++BuilderDelphiFiremonkeyIOSOSXWindows

FireMonkey 10.4.2 Features Updated iOS 14, Android 11, And macOS 11 Support Plus Hundreds Of Fixes

Sign up for our Newsletter and
stay informed

Leave a Reply