gpt4 book ai didi

java - 在 Activity 中显示转换后的文件

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:39:06 25 4
gpt4 key购买 nike

我正在 android studio 中开发视频转换器。我能够成功转换文件并可以播放生成的文件:

File file = new File(filepath);
Uri path = Uri.fromFile(file);
Intent Openintent = new Intent(Intent.ACTION_VIEW);
Openintent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
Openintent.setDataAndType(path, "audio/mp3");
try {
startActivity(Openintent);
}
catch (ActivityNotFoundException e) {

}

但我找不到任何代码来打开生成的文件夹并显示已标记的转换文件。就像我们在 Windows 中一样 Locate file in folder

最佳答案

这里是打开转换文件所在文件夹的方法

String folderPath = filepath.substring(0 , filepath.lastIndexOf('/') + 1);
Uri uri = Uri.parse(folderPath);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(uri, "resource/folder");
startActivity(intent);

关于java - 在 Activity 中显示转换后的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53985135/

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