-
Notifications
You must be signed in to change notification settings - Fork 505
[Bug][Android] File Picker exception when using third-party file managers #1444
Comments
I think the bug is that TakePersistableUriPermission() is called without checking if the content provider granted permissions: The code should probably look like this:
(or some variant of it). |
@vividos |
I meant the case when FileManager+ is used. Could you try if the |
@vividos Your example is incorrect I tried it. There is no error and I get the file.
But the result of this |
Let me check that when I'm at home. My guess is that the FileManager doesn't grant the permission, and then the FilePicker can't take the permission. |
@vividos I tested this pull request on 5 devices with Android 10, and it works well |
@mattleibow @jamesmontemagno @Redth |
I meant checking the result intent if the flag has been set, not the original intent:
Unfortunately, while reading about |
I tried out file picking using an Android 10 emulator and the File Manager Plus app installed. The app returns a result intent that doesn't have set the
I'm also interested what the Essentials devs think! |
@vividos I think it's better to delete this code at all Platform.AppContext.ContentResolver.TakePersistableUriPermission(contentUri, ActivityFlags.GrantReadUriPermission); |
Yes, maybe it's best, but then the Uri is not persisted between reboots and that may also be expected of the user of the library. And when you read the commonsware.com link, we would get another problem if more than 128 Uris are persisted per app, which may be unusual, but possible. |
But this will be the same for different file managers
How can we clear them? |
Please read the mentioned article, it's all in there. |
I expressed myself wrong |
@jamesmontemagno @Redth @mattleibow @vividos
Platform.AppContext.ContentResolver.TakePersistableUriPermission(contentUri, ActivityFlags.GrantReadUriPermission);
|
See this PR on the original FilePicker on why the call to |
HI folks, I am looking at this and I am a bit unsure of exactly what needs to be done. I see we have set the But, basically I see two sides:
However, since the |
In the past, in the FilePicker plugin, we had developers that grabbed the content Uri and stored it somewhere, expecting to be some kind of path that they can access indefinitely. So this is mostly a documentation issue. I would suggest to remove the persistent Uri stuff and add documentation that the FileResult is temporary and that files need to be copied to the app data folder or read immediately. I even would show some code using Stream.CopyToAsync on how to do it. |
I think this is the right way You should also not forget the cleaning when using the |
Description
An exception occurs when using third-party file managers.
Selecting files on WhatsApp app using this and other third-party file managers on phones that I tested works without errors.
Exception StackTrace
Steps to Reproduce
Basic Information
Screenshots
The text was updated successfully, but these errors were encountered: