ACTION OPEN DOCUMENT TREE only returns empty Recent folder

后端 未结 4 1524
眼角桃花
眼角桃花 2021-02-05 18:14

I have carefully copied the following code snippet from an earlier posting and it works, on the simulator and also on my Nexus 9 device, up to a point !

However, all I g

相关标签:
4条回答
  • 2021-02-05 18:28

    For me its working on emulator but not on real Android 5 phone. I even checked google android Directory Selection sample and it also did not work.

    So, its surely a bug whose effect can be seen on some phones.

    Report this bug to google and wait till it is fixed. Till then all you can do is to restrict access to memory card in your app, which is what you may not want to do. But I think there is nothing that we can do from our side before google fixes it.

    If you get any workaround for this you can tell me too.

    0 讨论(0)
  • 2021-02-05 18:32

    Others mentioned the option on DocumentsUI which the user should manually enable. However there is another option. Add these extras on to your ACTION_OPEN_DOCUMENT, ACTION_GET_CONTENT ,ACTION_CREATE_DOCUMENT or ACTION_OPEN_DOCUMENT_TREE intent. Explore button on Storage settings uses these extras while opening DocumentsUI app. I think the first one is enough to show Internal storage and sdcard. The others are good to have.

    intent.putExtra("android.content.extra.SHOW_ADVANCED", true);
    intent.putExtra("android.content.extra.FANCY", true);
    intent.putExtra("android.content.extra.SHOW_FILESIZE", true);
    

    Android 10

    I tried on Android 10 emulator and OnePlus 7T, "SHOW_ADVANCED" extra does not do anything. User should manually click to "Show Internal storage" on the three dot menu. SDCards are visible by default.

    0 讨论(0)
  • 2021-02-05 18:38

    I had the same problem as you do.

    I clicked "Show internal storage" in the overflow menu

    After that I was able to see "Internal storage" in the drawer

    0 讨论(0)
  • 2021-02-05 18:43

    Not sure if this is what you're asking but in the folder picker, where you're seeing only the recent folder, there's a overflow menu where you can toggle between show/hide SD Card.

    Overflow menu

    0 讨论(0)
提交回复
热议问题