For android 6 and above, if you want to perform some actions, for example set sound as ringtone, it’s not possible until user manually grants write permission for an app.
The problem is, this option is very hard to find for non-experienced android user. Accessing this option from application level is a must if it (app) needs such permission.
Few days ago found a solution for this problem.
Performed tests:
Android 4 - emulator - not working / there is no such setting. All apps have write permissions already granted.
Android 5 - emulator - the same as above
Android 6 - physical device (LG G4) - OK
Android 6 - emulator - OK
Android 7 - emulator - OK
Android 8 - emulator - OK
Activity Class is “com.android.settings.Settings$AppWriteSettingsActivity”
Set Data Uri with package name of your application (“package name” property of Screen 1 - in designer mode).
This won’t work with companion, app must be compiled to apk.
In this example, slider on “modify system settings” screen will be inactive. Because this application doesn’t ask for write permission.
New block would be nice, but I think even better would be extending block “when Screen1.Error Occured” to handle such situations easily.
Already made a topic on that →
If the app targets API level 23 or higher, the app user must explicitly grant this permission to the app through a permission management screen. The app requests the user’s approval by sending an intent with action Settings.ACTION_MANAGE_WRITE_SETTINGS. The app can check whether it has this authorization by callingSettings.System.canWrite().
Activity Action android.settings.action.MANAGE_WRITE_SETTINGS
Activity Data Uri package:com.baasapps.ringtone → package:your.Package.Name
call Screen1.Are System Write Settings Granted
Android 4 & 5 - always returns true - OK,
Android 6, 7, 8 - true if granted, false if not granted - OK
call Screen1.Open System Write Settings
Android 4 & 5 - function “does nothing”, I mean no go to settings screen and no error message - OK
Android 6, 7, 8 - opens system write settings screen - OK
All works as expected, good job!
Attached aia if someone wants to test (after compiling to apk) → checkwritesettings.aia (45,8 KB)
Activity Starter Data URI → Name of your package (like com.kodular.appname), you can get this automatically using TaifunTools extension
Purpose: When application is minimized, it will allow me to keep rendering a floating button or anything from your app you want, once this setting is enabled.