App Inventor Extensions: Settings | Pura Vida Apps

App Inventor Extensions


Settings Extension

See the App Inventor Extensions document about how to use an App Inventor Extension.

For questions about this extension or bug reports please start a new thread in the App Inventor community. Thank you.

For feature requests please contact me by email. To be a sponsor of a new method already is possible starting from only 10 USD! With your contribution you will help the complete App Inventor community. Thank you.

Sept 2nd, 2016: Version 1: brightness properties

Jan 17th, 2017: Version 2: volume properties added

Mar 7th, 2017: Version 3: ringtone methods added

Mar 26th, 2017: Version 3b: bugfix set ringtome for ALARM or NOTIFICATION

Apr 14, 2017: Version 3c: bugfix brightness

Apr 15, 2017: Version 4: new property brightness mode added

Apr 8, 2018: Version 5: new property font scale added

Oct 19, 2018: Version 6: new property to set font scale added

Feb 11, 2019: Version 7: because of the requirements of the SDK 26 release I now splitted the extension into 2 versions: a free version which works without write settings permissions and a paid version, which offers full functionality

Feb 13, 2019: Version 7a: to be able to set the volume of the Ringtone for >= Android N during DO NOT DISTURB mode: the permission ACCESS_NOTIFICATION_POLICY is required. Therefore the new method HaveNotificationPolicyAccess and the event NoNotificationPolicyAccess have been added into the paid version

Feb 14, 2019: Version 8: new method OpenAirplaneModeSettings added

March 18, 2019: Version 9 Interruption Filter added

May 11, 2020 (released: July 2nd, 2020): Version 9a: RingtoneSet method adjusted for devices > Android 10

Jan 12, 2021: Version 9b: androidMinSdk is 23 (Android 6) now added in manifest for paid version

Feb 16, 2022: Version 9c: internal procedure getMIMEType added to get the correct mime type to set ringtones

Jan 3, 2024: Version 9d: Extension rebuilt to avoid "ERROR: DX returned an error code" for projects, having 2 extensions or more which use proguard to obfuscate their code, see also Pull request 3004.

What are the differences between free and paid version?

Description

Settings extension.
Currently you can get/set the brightness, get/set the alarm/ring/music volume, get/set/play a ringtone and get/set the font scale, but probably more functionality will follow one day...
Required permissions for the free version: android.permission.READ_EXTERNAL_STORAGE
Required permissions for the paid version: android.permission.READ_EXTERNAL_STORAGE, android.permission.WRITE_SETTINGS, android.permission.ACCESS_NOTIFICATION_POLICY

Minimum API level is 23 (Android 6) for the paid version.

Properties


Get the brightness (a value between 0 and 255).

Thank you Tsiantakis Apps for being the sponsor of the brightness properties!


Get the brightness mode (MANUAL or AUTO).

Thank you Conor for being the sponsor of the brightness mode properties!


Returns whether User Interface shoud be shown while setting the volume.


Specifies whether User Interface shoud be shown while setting the volume.


Get alarm volume in percent.
Thank you Merciful for being the sponsor of this property!


Set alarm volume in percent.
Thank you Merciful for being the sponsor of this property!


Get music volume in percent.
Thank you Merciful for being the sponsor of this property!


Set music volume in percent.
Thank you Merciful for being the sponsor of this property!


Get ring volume in percent.
Thank you Merciful for being the sponsor of this property!
Note: to set Ringtone for >= Android N during DO NOT DISTURB mode: the permission ACCESS_NOTIFICATION_POLICY is required. Therefore the new method HaveNotificationPolicyAccess and the event NoNotificationPolicyAccess have been added into the paid version.
For the free version this property only works for devices below Android 9.


Set ring volume in percent.
Thank you Merciful for being the sponsor of this property!


Get font scale from the settings of the device, from settings > display > font = small/normal/large/huge
Thank you Boban for being the sponsor of this property!
on Nexus 5X these are the results: 0.85 = Small, 1 = Standard, 1.15 = Large, 1.3 = Very Large

Additional Properties for the paid version


Set the brightness mode (MANUAL or AUTO).

Thank you Conor for being the sponsor of the brightness mode properties!

Note: you will have to build the app before being able to set the brightness mode, because the companion app does not offer the permission android.permission.WRITE_SETTINGS.


Set the brightness (a value between 0 and 255).

Thank you Tsiantakis Apps for being the sponsor of the brightness properties!

Note: to set the brightness is only possible in brightness mode MANUAL. You can't set the brightness manually and have adaptive brightness at the same time!

Note: you will have to build the app before being able to set the brightness, because the companion app does not offer the permission android.permission.WRITE_SETTINGS.


Set font scale, a numeric value is expected as input parameter, for exampe 0.85 = Small, 1 = Standard, 1.15 = Large, 1.3 = Very Large
this snippet was used for this property.

Notes:

  1. This is an experimental method!
  2. Probably you have to restart your device to show effect.
  3. It is fully applicable for rooted devices and in unrooted devices some font may change and some may not
  4. You will have to build the app before being able to set the font scale, because the companion app does not offer the permission android.permission.WRITE_SETTINGS

Thank you BriFi for being the sponsor of this property!

Methods


Get current ringtone. Type can be RINGTONE, NOTIFICATION or ALARM.
Thank you James and chabooya for being the sponsors of this method.

Note: as Triratna found out here: after setting another ringtone outside of the app (for example in the default ringtone app), the extension does not refresh and still will display the previously set ringtone. As workaround, restart your app to get the correct ringtone.


Play ringtone. Type can be RINGTONE, NOTIFICATION or ALARM.
Thank you James and chabooya for being the sponsors of this method.


Stop currently playing ringtone.
Thank you James and chabooya for being the sponsors of this method.

Additional Methods for the paid version


Check, whether we have system write permission or not. Returns true or false. In case of false, the Android permissions menu of the app will be opened automatically.


Check, whether we have notification policy access (for >= Android N) or not. This is required to be able to set the volume of the Ringtone for >= Android N during DO NOT DISTURB mode. Returns true or false. In case of false, the Android notification policy menu of the app will be opened automatically


Set sound file as ringtone, notification and/or alarm sound. Title is a custom name for the sound. Type can be RINGTONE, NOTIFICATION or ALARM. The sound file must be stored on the internal sdcard and in mp3 format. For files from the assets, copy them first to the internal sdcard using the file extension. Prefix the fileName with / (i.e. relative path) to look for the file on the internal SD card. For instance /myFile.pm3 will look for the file /mnt/sdcard/myFile.mp3. If fileName starts with file:/// you can specify a complete path to the file.

Note: you will have to build the app before being able to set the ringtone, because the companion app does not offer the permission android.permission.WRITE_SETTINGS

Note: It has been reported, that this method did not work on Huawei EMUI Version 10.0.0 devices. After upgrading to EMUI Version 10.1.0 this problem has been resolved.

Thank you James and chabooya for being the sponsors of this method.


Opens the Airplane / Flight Mode settings screen for the user. Thank you Samuel for being the sponsor of this method.


Sets the current notification interruption filter. Possible values for filter are NONE, PRIORITY, ALARMS or ALL. Default is ALL.
Usually you would toggle between ALARMS to enable the Do not Disturb mode (but alarms still will sound) and ALL to disable the Do not Disturb mode. Note: you will have to build the app before being able to use this method, because the companion app does not offer the permission android.permission.WRITE_SETTINGS. Also Notification Policy access is required to be able to use this method.
Thank you Samuel for being the sponsor of this method.

Additional Events for the paid version


Event indicating that system write permission has not been granted.


Event indicating that notification policy access has not been granted

Example App: Settings Test





Example App: Ringtone Test

Note: you will have to build the app before being able to get or set the ringtone, because the companion app does not offer the permission android.permission.WRITE_SETTINGS. Before testing make sure the target directory to copy the soundfiles to is empty. The target directory must be in shared storage. For more information see also the overview. The example project uses /Download/Sounds.



Questions and Answers

Q1: I use the button to set music volume to 86% and then the timer reports after 2 seconds that the volume is 81%. I find that the volumes continue to deprecate until they hit a plateau of 100%, 75%, 50% where they will stay.
A: Your observation is correct. This happens, because the extension uses percent values to set the volume. The devices however use different volume values and this is also different by device manufacturer. For example my Samsung Galaxy A54 device uses 15 different volume values, translated in % these values are: 0, 6, 13, 20, 26, 33, 40, 53, 60, 66, 73, 80, 86, 93, 100%.

Test

Tested successfully on Samsung Galaxy A51 running Android 11.

For questions about App Inventor,
please ask in the App Inventor community.Thank you.

Test the functionality of the Settings extension

The settings test app as well as the ringtone test app are available in Google Play. You can test the examples following these steps

  1. Follow the opt-in URL to get access to the settings app and to be able to download it to your device. Follow the opt-in URL to get access to the ringtone app and to be able to download it to your device. It might take a few hours for Google to enable you as beta tester!
  2. Start testing.

Buy the full version of the Settings extension for App Inventor


You can buy this extension (aix file).
With your payment you accept the terms and conditions below.

Payment options

1. Paypal

Please transfer 12 USD via Paypal
to Pura Vida Apps

2. Bitcoin

After having received your payment I will be happy to send the download link to you. Please let me know your Google account! I usually will send the download link not later than 24 hours after having received your payment.
Thank you! Taifun


Terms and Conditions

Free version of the Settings extension

The free version works without write settings permissions and offers restricted functionality. See the documentation above about which blocks are available or not.

Terms and Conditions

Download the free version of the Settings extension


Developing and maintaining snippets, tutorials and extensions for App Inventor takes a lot of time.
I hope it saved some of your time. If yes, then you might consider to donate a small amount!

Donation amount:

or donate some mBTC to Bitcoin Address:
1Jd8kXLHu2Vkuhi15TWHiQm4uE9AGPYxi8
Bitcoin

Thank you! Taifun
 

Download free version of the Settings extension (aix file)

Back to top of page ...

Creative Commons License
This work by Pura Vida Apps is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License
with attribution (name=Pura Vida Apps and link to the source site) required.


Home | Snippets | Tutorials | Extensions | Links | Search | Privacy Policy | Contact