What do you mean by that? DefaultFileScope = Legacy changes the storage permissions that are declared in the Manifest.
However, this does not affect whether the app is rejected in the Play Store or not.
Well, I believe there is because it is effectively circumventing Google's security measures (Android 11), but Anke thinks there is not. Anke is the expert Power User in file handling/paths. The help says that Legacy will not work on Android 11 +.(via App Inventor).
Your work-around Topic is a great help to everyone. It would be good if App Inventor had a switch that everyone could understand e.g. 'For Android 10 and below' and 'For Android 11 and up'.
You can not make a switch for the relevant android versions. We remember that Apps are not created under a given version of Android. Apps must be universal and work the same under every version of Android.
It's best to move your thinking, towards Android 11, and forget that in older versions it was possible to save files in any folder. Create all new Apps by using Android's behavior 11. Even when we create and test APP on Android 9 or older. So we use ASD and shared folders.
if in doubt, let's take a look together into the App Inventor sources
Legacy: Operations should occur using legacy logic (pre-nb186). This may break on newer Android
versions and make apps incompatible with Google Play Store guidelines.
That has always been the aim Patryk but the new rules on external directories have made it impossible for Android 11 Apps to support their own external paths and those who are sticking with Android 10 and below wish to continue with that capability. I'd like to see the world-wide figures on Android 11, I'm guessing that much lower versions completely out weigh it as there are whole countries where most of the population cannot afford the current super-expensive phones.
You can continue older behavior for older android versions, but only if we use such an app on our phone or for educational purposes. But I think that science no already supported methods is not a good idea, if we provide this app in the Play store, it will be rejected because it would be impossible to use it on the new Android. I think we should bring everyone on using new methods, regardless of the Android version so that it does not make a greater mess than it is.
So if I understand correctly, using the defaultfilescope in legacy mode will prevent me from putting it on google play due to it going against security or regulation standards?
What would be a reliable solution? because I will have a LOT of savable blocks in this app and before I start expanding it I would like to have a usable solution which will work 100% on older and newer versions of android.
Going with the legacy mode though is great if you don't plan to distribute it over google play!!
Thanks all and I will will wait patiently if someone has a solution.
You could check my guide: (take a look at section 1-2: using the camera)
In the guide I mention that a proper way to save to external is to use shared folders. This is future-proof. If you follow my guide, you won't have problems with write permissions, and also you don't need to change the project's file scope. What I propose is to use the Pro Camera extension, which doesn't rely on write_permissions. Still you'll have to save the photos either in the ASD, or a shared folder (/Pictures or /DCIM). Writing to those directories does not require WRITE_EXTERNAL_STORAGE and is recommended by Android.
I first mentioned it here in this thread.
What I didn't mention though is that it's future-proof. It doesn't rely on outdated permissions or legacy mode. It's pure API 30+ compatible protocol/method.
Please let me summarize one more time:
The camera component is broken: you can replace it with Pro Camera extension.
The file component is broken: you can replace it with TaifunFile extension.
Done! API 30 is yours.
You're future-proof. No manifest editing, no flags setting, nothing.
You write into the shared folders, and that's what android wants you to do.
Final disclaimer: I really don't know what "legacy mode" is. I'm not sure it's an outdated thing. The opinions vary.
From the AI2 reference page we get this:
Legacy: Files will be read from and written to the file system using the App Inventor rules prior to release nb187. That is, file names starting with a single / will be read from and written to the root of the external storage directory, e.g., /sdcard/ . Legacy functionality will not work on Android 11 or later.
But, I'm asking, /Pictures (for example) is not a valid shared folder path? In my understanding, it probably is. But maybe I'm wrong, and the only up-to-date way is to use full path (/storage/emulated/0/Pictures). I know full path works (without legacy mode). But not on the built-in components.
What is a full path anyway? (I'm getting philosophical here). There are just mount points. And what we call "file scope" sounds like "mount point" to me. But back on track, /storage/emulated/0/Pictures/myphoto.jpg is considered a full path and works well with components/extensions that don't rely on write_external permission.
huge thanks for this. I was able to get the camera visible and take a picture but I am not able to see the taken foto in my image block. Those are my blocks.
I fixed the 2 typose but it didn't work. I added the permissions but that also didn't work in the end it was: set Image2.Picture to file:///storage/emulated/0/pictures/test.jpg
I have no idea what all of you are talking about here. What should this have to do with the Play Store and the Google Play Store guidelines?
I think, nothing.
It just ensures that the storage permissions (READ / WRITE) are both declared in the Manifest and specifies how paths are handled by components that can save / read something (e.g. Canvas).
I set DefaultFileScope = Legacy to ensure that WRITE is declared in the Manifest (for devices with Android < 10), and override Legacy for the File component if necessary.
Try this APK on all Android versions (especially Android 6 - 9, 10, 11):
The app saves a text file in the ASD (for devices with Android 10+) and copies it from there to the shared storage (e.g. /Download/myTextFiles/... and read it from there (of course without storage permissions). For devices with Android < 10, the text file is directly saved in /Download/myTextFiles/ and read from there (WRITE permission is required). The same with the Canvas component.