Android Question Content Chooser is not working on Samsung devices

Rokko

Member
Licensed User
Hello everyone,

I've got a huge problem with Content Chooser. It was always working properly but since recently it stopped working correct on some devices. Mostly Samsung.

If the user choose an image from gallery, Google Drive, Dropbox, documents etcetera everything is working as expected but on some devices there is also this folder called "My Files" or similar. If the user chooses an image from this folder
B4X:
GetFileInfoByIndex("_display_name", FileName)
gives back an emty string and it can not be saved or uploaded to our server.

I'm using the code under https://www.b4x.com/android/forum/t...-received-shared-file-example.117325/#content and I'm in an urgent need to find a solution for this issue. Someone any ideas?

Thanks in advance!

Regards, Rokko
 

DonManfred

Expert
Licensed User
Longtime User
Can you upload a small example showing the problem?
 
Upvote 0

Rokko

Member
Licensed User
You can use the Example App from the link above and a Samsung device with Android10 or later. I've implemented it the same way as shown in the excample and it worked all the time. Until now.

I can see differences in the image path. If the image comes from gallery the path is:
B4X:
content://com.google.android.apps.photos.contentprovider/-1/1/content%3A%2F%2Fmedia%2Fexternal%2Fimages%2Fmedia%2F24/ORIGINAL/NONE/image%2Fjpeg/287500494

but the same picture chosen in "My Files" gives back the following:
B4X:
content://0@media/external/images/media/24

Seems like the path from "My Files" is missing the link to the picture itself. But how to solve this?
 
Upvote 0

edgar_ortiz

Active Member
Licensed User
Longtime User
The same thing happened to me, with an application that uses a client.

I DON'T remember exactly, but it was resolved "in the phone settings", giving it "permission to access my files" or something like that.

Without modifying the application code.

I hope it helps you
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
Seems like the path from "My Files" is missing the link to the picture itself. But how to solve this?
I have Samsung phone S10e. with OS 11. When I click 'Choose File', I do not look in MyFIles. I look in a folder that has the name: Galaxy S10e and browse to the chosen file and click it. All info shows. See screenshot attached. What Samsung [hone do you have. If this is not what yu are looking for, keep asking.
 

Attachments

  • ForRokko.png
    ForRokko.png
    53.9 KB · Views: 194
Upvote 0

Rokko

Member
Licensed User
Hello,

none of the hints above helped me. I was really busy in the last days to find a solution and had to make store updates for many, many apps. At the moment my own solution for this issue is to check the path and if the user choose a file from the "My files" folder I show them a message that they should pick it from gallery or documents.

But I think that is not really user friendly and I'm still hoping that someone comes up with a solution. Because I think for users it's much better if they could choose attachements from every folder they have access to.

And while I was updating so many apps I had a look in Googles stats and it seems like there are more affected devices than only Samsung. Seems that it can happen on some Huawei, ZTE and Xiaomi devices too.

My guess is that there are only soft links in the "My files" folder and that's the reason it doesn't work.
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
Take a look at post #33 by klaus and closely look at his PC tree, you will see a folder called: S10 de klaus. It is not called 'MyFiles'There is no reason why you should not see something like that on your PC if device is Samsung (folder name may slightly differ depending on your device name). Please note that I used the below thread just to show you the folder name only.
 
Upvote 0

Rokko

Member
Licensed User
Seems that we're talking about different things. I mean the file explorer directly on the device. Like if you are sharing pictures on Facebook, Twitter or even this forum. If you click the add attachment button the device's own file manager open. As you can see in the first row of the first image you can choose different folders to search for pictures or documents you want to share. Every folder is working fine even documents from Dropbox or Google Drive but on some devices you can also see a folder called "My files"(not in the attached image, on Xiaomi Redmi the folder was removed with the Android 11 update). In this folder you can see every files on your phone it doesn't matter if they are stored in pictures, DCIM, screenshots, documents... But if the user pics a file out of the "My files" folder it doesn't work. You can see the difference in the paths from post #3. And there's the problem.
My guess is that is has something to do with the changes they made with sdk 30. Maybe that are only soft links or it has something to do with permissions like it was mentioned in post #4. I don't know. Maybe we need a new library because we are using the same code as in Erel's example(link in the first post). If you have access to a device that have that "My files" folder you can check it out by yourself. Just compile the example. Doesn't work with the "My files" folder. On older Samsung devices, I have an old S7 with Android 7.0, you can find that folder too but there it is still working properly.
 

Attachments

  • IMG_20211223_003753.jpg
    IMG_20211223_003753.jpg
    421.7 KB · Views: 155
  • Screenshot_2021-12-23-00-28-06-710_com.mi.android.globalFileexplorer.jpg
    Screenshot_2021-12-23-00-28-06-710_com.mi.android.globalFileexplorer.jpg
    192.1 KB · Views: 185
  • IMG_20211223_003753.jpg
    IMG_20211223_003753.jpg
    421.7 KB · Views: 162
  • Screenshot_2021-12-23-00-28-06-710_com.mi.android.globalFileexplorer.jpg
    Screenshot_2021-12-23-00-28-06-710_com.mi.android.globalFileexplorer.jpg
    192.1 KB · Views: 177
Upvote 0

Mahares

Expert
Licensed User
Longtime User
On my phone, I can see both My Files and Galaxy S10e. When I click on 'My Files', I cannot select any files, but I can select the file when I click on Galaxy S10e and display the file name for the file that I could not select when I clicked on 'My Files'. See screenshot. Are we still talking about different things. If we are then, I hope someone can understand your problem better and answer.
1640222695037.png
 
Upvote 0
Top