Jim 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;
Result := TJSettings_System.JavaClass.putInt(
end; Head over and read Jim’s full blog post about the system settings API.
FMXExpress.com has over 700 tips and tricks for building cross platform apps on Android, IOS, OSX, Windows, and Linux with a single codebase and single UI using the FireMonkey framework found in Delphi and C++Builder.
FMXExpress covers top cross platform secrets for FireMonkey in C++Builder and Delphi XE5, XE6, XE7, XE8, Seattle, Berlin, Tokyo, Rio, and Sydney.