代码之家  ›  专栏  ›  技术社区  ›  m.qayyum

在活动中显示转换的文件

  •  9
  • m.qayyum  · 技术社区  · 7 年前

    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) {
    
    }
    

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

    1 回复  |  直到 7 年前
        1
  •  4
  •   Ali Faris    7 年前

    下面是如何打开转换文件的包含文件夹

    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);