I have an app that writes to a shared folder (/Music). It works fine in API 30, but in Android 9 it doesn't move files to /Music.
Do I need to ask for WRITE permissions specifically for older android phones, and if so, what is the best current method? Do I just ask for the write permission and ignore the message in android 11 (permission not found)? Or is there some kind of check I could do? Thank you very much
In the Screen1 blocks there is a PlatformVersion block. You can use this as a test condition as to whether to ask for permission or not on first run, depending on the Android version of your device. You may need to run a list because some of the numbers are not straightforward e.g. 4.2.2
If this doesn't work then the FileTools extension and the KIO4_base64 extension offer a block that returns the API, but this might always returns 30 or higher (futureproofing post here...)
Both appear to work as required, tested with companion 2.61u on android 10 (29) and android 11 (30)
Nice. The PlatformVersion block works great. One note: I needed to strip any decimals to be able to compare it numerically. Because it returns something like "6.0.1" but in other phone it returns simply "11". My blocks (working good):
Note: Asking for WRITE permission on Android 10 is only possible because AI2 has decided to continue to declare requestLegacyExternalStorage (even after the targetSdkVersion = 30 update) in the Manifest.
But there is no longer any component that can store something in external storage. So that would only make sense if you want to save something there by means of an extension. But then files are saved under different paths under Android 10 and 11 (Android 10: in the external storage and Android 11: in the ASD). However, if this is not desired, it makes no sense to request WRITE permission under Android 10, as this permission is not required there.