gpt4 book ai didi

file - 无法获取用于从 Android 中的 MI-Oreo(MI-A2)设备的下载文件夹中选择任何文件的 URI

转载 作者:行者123 更新时间:2023-12-02 09:10:40 25 4
gpt4 key购买 nike

我需要帮助来获取我们通过 Intent 从下载文件夹或任何其他文件夹中选择的内容的文件路径。我附上 fileUtil我一直在使用的类,它在牛轧糖版本之前运行良好。但是对于 oreo 以及在某些特定设备中也是如此,我们收到一个空路径作为返回。因此,如果有人遇到过此类错误并找到了解决方案,请在此处分享。

if(resultCode ==RESULT_OK)
{
final Uri uri = data.getData();
// Get the File path from the Uri
String path = FileUtils.getPath(this, uri);
// Alternatively, use FileUtils.getFile(Context, Uri)
if (path != null && FileUtils.isLocal(path)) {
//File file = new File(path);
this.file = new File(path);
profile_imagepath = path;
filename = file.getName();
txtselectedfile.setText(filename);
}
}

最佳答案

你可以尝试使用ACTION_PICK对于 26 以上的 api 级别来解决此问题,而不是使用 ACTION_GET_CONTENT .尝试并希望这对您有所帮助。

关于file - 无法获取用于从 Android 中的 MI-Oreo(MI-A2)设备的下载文件夹中选择任何文件的 URI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52658893/

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