是否可以使用存储访问框架实现 Google Drive 文件夹选择器对话框?

Cro*_*ile 7 android google-drive-api storage-access-framework google-drive-android-api google-drive-picker

我的应用程序要求用户选择一个 Google Drive 文件夹,以便以后可以将文件保存到选定的文件夹中。

到目前为止,它使用 Google Drive Android API 的文件夹选择器 UI,但现在已弃用并关闭。迁移说明建议使用存储访问框架(又名 SAF)来替换以前可用的文件选取器 UI。

问题是,当我尝试使用 ACTION_OPEN_DOCUMENT_TREE 操作启动 SAF UI 时,Google Drive 没有显示。另一个 Stackoverflow 帖子表明SAF不支持选择 Google Drive 文件夹,这很奇怪,因为它是一个非常重要和基本的功能。

有什么方法可以为 Google Drive 实现文件夹选择器 UI,而不必自己从头开始构建它?

 val intent = Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
 startActivityForResult(intent, 3);
Run Code Online (Sandbox Code Playgroud)