Closed krishrajchal closed 1 year ago
Unfortunately, Android prevents selecting the root directory and Downloads on newer Android versions while "Browse..."ing. Overcoming it requires MANAGE_EXTERNAL_STORAGE permission being granted from Settings but unless your app is strictly a file browser app, Google Play can reject your app due to this permission.
You may also use NativeFilePicker if you're only interested in picking files (and you're picking common file types like pdf, jpg, etc.).
When I was trying to make it work, I had a plugin that asked for the MANAGE_EXTERNAL_STORAGE permission. Even with permission, it still had that menu.
Hmm, could you set this field to false via Reflection and try again: https://github.com/yasirkula/UnitySimpleFileBrowser/blob/db6c74e751238113ca9d1d19c19c580e6628687d/Plugins/SimpleFileBrowser/Scripts/FileBrowserHelpers.cs#L80
#if !UNITY_EDITOR && UNITY_ANDROID
typeof(FileBrowserHelpers).GetField("m_shouldUseSAF", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(null, (bool?)false);
#endif
Where does the reflection go?
Awake is a good candidate.
NullReferenceException on the reflection part.
Did you include #if
part in your code? You must, if you didn't. PS. Oh wait the field is static. You should change BindingFlags.Instance to BindingFlags.Static.
Good thing it works but, there are some warnings that may prevent it from working on the Google Play Store. I will try to fix them:
Accessing hidden method Landroid/os/storage/StorageVolume;->getPath()Ljava/lang/String; (max-target-q,test-api, reflection, denied)
If this is a platform test consider enabling VMRuntime.ALLOW_TEST_API_ACCESS change id for this package.
Does replacing SimpleFileBrowser.aar with the one inside this zip archive resolve the issue?
That worked, now, those warnings are not there and the nav button is visible too (previously not showing).
Description of the bug
When I used the plugin before, I remember being able to select files from the Internal Storage. Now, when I press the browse button, it shows "Can't use this folder, To protect your privacy, choose another folder."
I set these permissions in the manifest: READ_EXTERNAL_STORAGE WRITE_EXTERNAL_STORAGE MANAGE_EXTERNAL_STORAGE
tools:node is replace requestLegacyExternalStorage is true
Reproduction steps
Open using ShowDialog with allowMultiSelection true and PickMode to FilesAndFolders Press on browse
Platform specs
Additional info
No errors relating to the plugin or unity: libprocessgroup set_timerslack_ns write failed: Operation not permitted