【发布时间】:2018-01-02 16:21:17
【问题描述】:
我想使用 Intent 打开特定路径文件夹,我使用了文件资源管理器的代码,它运行良好,但在某些设备(三星设备)中,如果文件资源管理器应用程序不可用,则它不会打开特定路径的文件夹。 我尝试了很多解决方案,但它对我不起作用。
Uri uri = Uri.fromFile(new File(new File(filePath).getParent()));
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(uri, "resource/folder");
if (intent.resolveActivityInfo(getPackageManager(), 0) != null)
{
startActivity(intent);
}
else {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setDataAndType(uri, "file/*");
startActivity(Intent.createChooser(intent, "Open folder"));
}
【问题讨论】:
-
我试过了,但它也会打开文件管理器,但不会跳转到特定文件夹
-
你找到解决办法了吗?
-
@FarooqArshed 还没有