gpt4 book ai didi

android - 如何从图库中选择文件?

转载 作者:行者123 更新时间:2023-11-29 00:21:47 26 4
gpt4 key购买 nike

我想选择一个文件(图像、视频或音频除外),如 pdf、ppt、docx、txt 等,,

Intent intent = new Intent();
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select File"),Constant.SELECT_FILE);

以上方法无效。

当我执行操作时,出现对​​话框并显示消息“没有应用程序可以执行此操作”

最佳答案

因为没有在设备上安装任何应用程序来处理您的 Intent 操作 Intent.ACTION_GET_CONTENT。因此,如果您的设备运行的是 Android 4.4,请尝试使用 Intent.ACTION_OPEN_DOCUMENT 或实现您自己的文件浏览器 Activity 。

https://github.com/vaal12/AndroidFileBrowseraFileChooser

关于android - 如何从图库中选择文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22506448/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com