Displaying Image from "external_storage" not working in compiled apk

There seem to have been a few posts about loading images from storage, but nothing has helped me and i’m a little stuck…

I have created a little app to show my problem, so I can share / explain as I go along…

I am trying to display a picture from my sdcard, this seems to be working fine in the companion app, but doesn’t display when I use the exported apk.

I have also used filetools to validate the files exist and the do, they are just not displayed

My blocks based around the issue I am seeing -

This screenshot show the app running via the companion on my phone, the top two lines of text should be “wrong” as i am unable to “share image to” via the companion, but i hardcoded an image from the same telegaram folder as i will share from, and that is “true” for existing and displays

this screenshot is from my phone using the apk, at this point i have shared a picture to my apk via telegram, so the text at the top is now valid, and as can be seen, but hardcoded and the dynamic picture i just shared are both coming back with existing “true”, but neither picture, even the hardcoded one from the companion is displayed…

Here is the app permissions

Hope someone has some idea, as im a little stumped by what im doing wrong.

Thanks

Karl

Probably you should try converting content uri into path using PathFromUri block.

is file:///storage/emulated/0/0Telegram/TelegramImages/xxxxx.jpg not already in path format?

Yes it is.
What’s your android version?

Oneplus 8 running Android 11

This seems to be issue as Kodular only bumped max/target SDK.
I’ll suggest you to test the same logic in AI2.

yeah it works in AI2.

what happens, if you restart your apk file (i.e. after the Read permission has been granted)?
will the image be displayed then?

Taifun

Nope, nothing, I have uninstalled and reinstalled it, and set the permissions, but nothing :frowning:

this is not a question about reinstalling… you first have to grant the permission before you can access and display the image… you added the AskForPermission block during Screen.Initialize and continue to display the image without having received permission to access to the file…

therefore my guess is, it only does not work the first time, but might work all further times you start the app

Taifun

Ok, i’m not “clueless” when it comes to all this stuff, and have tried alot before having asked here…

I have installed, allowed it to request, fully close the app, then reopen it, it doesn’t display.

I showed a screenshot of the app permissions on my phone, after the first request it hasn’t asked again…but the image is not displayed, again notice that the “fileExists” command is saying true for both “images” so its able to see them, but not display.

And this DOES work via the companion app, just not when its compiled as apk.

I have modifed the apk to load a file from the root of an sdcard (emulated external storage), I have placed my image “test.png” of the root of the sd card, it shows in companion, but not in apk, maybe you can try it? you need to click the button on the first page to go to the second (as im also trying to accomplish this by sharing an image to my app)

newtest.apk (5.2 MB)

Interestingly, this does load the .png from the root of the sdcard when I run as an apk…

so maybe we can only load from the direct root?

As the exact same code, also says the image in the telgram folder is present, but doesn’t display it…strange

as test keep the AskForPermisson block in the Screen.Initialize event and move all other blocks into for example a button click event
it should be possible to display the image from any folder after having received READ_EXTERNAL_STORAGE permission, see also the overview Some basics on Android storage system - #24 by bodymindpower

Taifun

I notice that the path for the image from telegram contains a space,

file:///storage/emulated/0/Telegram/Telegram Images/858105162_345555.jpg

should this be escaped or something maybe? or is this not needed in kodular?

thanks

You could replace the space by %20 to find out, if this makes a difference

Taifun

Can you try any other folder that is not created by any app(manually create a folder).

This shouldn’t be a problem.

Try this APK → imageTest.apk (5.9 MB)

Copy foto.jpg from the assets into this path beforehand:
/storage/emulated/0/Telegram/Telegram Images/foto.jpg.

grafik

Android 11:

So I made a little test app this morning to try this again…


newtest.apk (5.3 MB)
newtest.aia (100.5 KB)

This has a test.png as an asset, and on pressing the copy button will copy that image to

  • root of storage (/emulated/0/)
  • folder in root of storage (/emulated/0/ktest)
  • folder with space in root of storage (/emulated/0/k test/)
  • telegram image folder (/storage/emulated/0/Telegram/Telegram Images/)

it then reloads and shows filetools exists true/false + the full path, then the image.

this all works on the companion -

but doesn’t work atall on my phone, even the copy command isn’t working, even though i have storage permissions and request permissions at the start of the app, as per the blocks aia -

little stuck for ideas now :frowning:

Please see video, your app also doesn’t work for me…