alexrintt / shared-storage

Flutter plugin to work with Android external storage.
http://alexrintt.io/shared-storage/
MIT License
53 stars 24 forks source link

Losing access to folder contents after device reboot #118

Closed Tamerlanchiques closed 1 year ago

Tamerlanchiques commented 1 year ago

Hi!

My case is in-app music player. User opens some directories (openDocumentTree) and watch music content in the app UI.

All works fine till device reboot. After reboot I see list of persisted folders (persistedUriPermissions) but when I trying to access contents of folder I get "No permission granted" error. Ask user for granting permissions each time is not user friendly and I looking for solution on this issue.

Watched your example app but seen same problem there: list of persisted uris and no permission on reading contents each device reboot.

https://user-images.githubusercontent.com/11006352/230379868-5f16f3a9-af1b-47b0-a6e5-76438f428cdc.mp4

Quick demo of problem.

After some research I found that we need strictly specify that we need grant access across device reboots . As I can see your openDocumentTree function has parameter 'persistablePermission' that looks like granting permissions across reboots is default behaviour but seems not work.

So… what can I do for granting folder contents read permissions device across reboots?

Tamerlanchiques commented 1 year ago

https://alexrintt.io/shared-storage/Usage/Storage%20Access%20Framework/#opendocumenttree

// whether or not the selected URIs should be persisted across app and device reboots. persistablePermission: true,

изображение

shinexoh commented 1 year ago

Yes bro I'm in the same situation as you -_-

alexrintt commented 1 year ago

What is your Android version?

Tamerlanchiques commented 1 year ago

Emulator Android version on the related video demo is Android Q (10), 29 API level.

Problem keeps on real devices (Huawei and Samsung tablets).

alexrintt commented 1 year ago

Already fixed, I'll be pushing a new version 0.7.1 to fix this behavior in a few hours. Thank you very much for your detailed issue, this is a huge help on bug reports.

Tamerlanchiques commented 1 year ago

Oh… A significant event in my life: the first such case of contribution to the open source :)

alexrintt commented 1 year ago

Welcome to the club :)

alexrintt commented 1 year ago

Released 0.7.1, please, run flutter pub get to update the version, or explicitly set (recommended):

dependencies:
  # ...
  shared_storage: ^0.7.1

I'll close this issue, but if this same issue persists feel free to re-open. You can also see the fix here.