Read image file located in ASD

Some users who use my application on Android 11 devices are experiencing the problem of not being able to read cropped images with my app within it.
I learned that on Android 11 the cropped images are saved inside the ASD, but when I try to read them from the ASD, the app doesn’t load them.
How can I solve? I am attaching the blocks I am using for this process explaining how they work gradually:
Immagine
With these first blocks I activate the Pick Image, leading the user to select the image he wants to insert in the app from the gallery of his device.
These blocks work correctly.


With these second blocks active, after choosing the image to insert and crop, the Dialog that allows the user to crop the chosen image in the size he prefers (always a square), then by pressing a button, the image is cropped.
These blocks also work correctly.


With this last block I take the image cropped from the previous blocks (saved inside the ASD of my app) and insert it inside the components.
And here is the problem: the image is not read if it is inside the ASD.
I tried to copy said cropped image to another location and if it is inside /storage/emulated/0 it is read, but on Android 11 such a thing cannot be done (in fact my users complain that cannot see the cropped image in the app even with this method).
Is there a way to read then the image files created inside the ASD?

The path I am using and involving my ASD is the following:
file:///storage/emulated/0/Android/data/io.kodular.andreapetricola.LoRCardCreator/files/LoRCardCreator/croppedimg.jpg (I did not preformat it because it was too long and the post was cut at the end)

2 Likes

Copy the image from the ASD to a Shared folder, e.g. /Pictures and read it from there.
imageTestASD_shared.apk (5.9 MB)

In my test APK the image is first copied from the assets to the ASD and from there to the shared storage / folder: /Pictures.
This works without WRITE / READ permissions. See also → here.

Android 11:

1 Like

Note:
If the app is uninstalled and reinstalled after the image (photo1.jpg) was already created (in /Pictures), then the app needs READ permission, because the image is then no longer created by the app itself.

Ok, with the path file///storage/emulated/0/Pictures/ the image is read correctly.
But now this message appears.


Although the image is read normally and then deleted immediately afterwards (to avoid creating clones of the same image cropped in the gallery), it warns me that I have not granted write permissions.
Yet I have placed the blocks that give access to these permissions, they are these:


How is it possible? and how can I get rid of this problem?

Does my test APK work for you?

I just installed it, pressed the button and it gave me this result.


Unfortunately I have a device with Android 10, I opened the topic because my app is on the store and many have downloaded it, including those who have Android 10 (and who do not complain of any problem) and Android 11 (they have the problem from me mentioned).

It should actually work the same way on Android 10. Apparently it doesn’t (for whatever reason).

I adjusted the app a bit so that it should now work on all Android versions:
imageTestASD_shared2.apk (5.9 MB)

Maybe some can test this (with different Android versions) and post screenshots.

I have tried it and this is the result.


Before making it appear it asked me to access the storage and I allowed it.

But in all of this, the last problem I mentioned how can I solve it in the end?

As I said and showed, on Android 11 no permissions are required for this.
So try my test APK on a Android 11 device.

1 Like

Unfortunately I only own an Android 10 device (my Galaxy A7 2018).
The errors shown that occurred on the Android 11 device were mentioned to me by users using my app.
Does this mean that on an Android 11 device the error message 908 I put in my last post will not appear? Is there a way to make it disappear from other devices? Because it keeps appearing on mine.

Yes no permission was asked.

Yes, on Android 11. And it should work the same way on Android 10, but it doesn’t (this should be fixed). EDITED Sept 28, 2021

1 Like

1 Like

@India_Learn Correct, thanks, I checked it again.
(Apparently my first attempt failed because the file already existed in the folder before and was then deleted. So I just had to change the filename.)

Can you please share this aia file I have similar problem in my project.

I am using Juan Antonio’s extension com.KIO4_Base64.aix to convert file to Base64 string.
I am able to convert image, video and audio files to base 64 string.

Fine, so where is the problem?

@bodymindpower Thanks for reply.
I was using old version of extension com.KIO4_Base64.aix that’s why it was not working on android 11 device.
Still I am not able to convert pdf file (located in Download folder) to base 64 string.
Is Download folder not a shared folder? How can a file be copied to ASD from Download folder?