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;
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.