android - 在 android 中通过 intent 浏览文件时排除 google drive 选项

标签 android google-drive-api filechooser

这是一个被问及的问题,但我没有使用该解决方案解决它。 这是我的代码

Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
Uri uri = Uri.parse(Environment.getDownloadCacheDirectory().getPath().toString());
intent.setDataAndType(uri,"*/*");
intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
intent.addCategory(Intent.CATEGORY_OPENABLE);
try {
    startActivityForResult(Intent.createChooser(intent, "SELECT FILE"), commonUtilities.FILE_REQUEST_CODE);
} catch (ActivityNotFoundException e) {
}

仍然有 Google 驱动器选项。我只是不想显示谷歌驱动器选项。

我怎样才能得到它,帮帮我。进阶致谢

最佳答案

I just want not to display the google drive option.

想要什么并不重要。您的用户想要什么很重要。您的某些用户可能希望从 Google 云端硬盘、本地网络上的文件服务器以及他们在其设备上配置的支持 ACTION_GET_CONTENT 的其他地方获取内容。

除此之外,一般来说,您无法控制 ACTION_GET_CONTENT 向用户提供哪些选项。

因此,如果您不希望 Google Drive 作为一个选项出现,请不要使用 ACTION_GET_CONTENT(或 ACTION_OPEN_DOCUMENTACTION_CREATE_DOCUMENT 等.).做点别的,比如集成 file-picker library .

关于android - 在 android 中通过 intent 浏览文件时排除 google drive 选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46861766/

相关文章:

java - Intent.FLAG_ACTIVITY_CLEAR_TASK 的替代方案

java - 如何使用可中断 channel 下载文件? (蔚来)

java - 代理背后的 Google Drive API Java 客户端

JavaFX - 中心文件选择器弹出窗口

ubuntu - Anaconda 中的 FileChooserDialog 图标损坏如何修复?

android - 与 .apply 一起使用时,修饰符不起作用

android - compileSdkVersion、minSdkVersion、targetSdkVersion 应该怎么设置才能支持Marshmallow to Pie?

google-drive-api - Google Picker 未按文件扩展名进行选择

python - 通过 Python 从 Google Drive 备份文件

javascript - 适用于 Evernote 和 OneDrive 的文件选择器 API