1

我想通过 Android 文件管理器选择一个文件。

所以,打开文件意图代码是

Intent intent = new Intent();
intent.setType("file/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent,"Select File"), 1);

但是我无法访问三星设备中的文件管理器来解决这个问题

Intent intent = new Intent("com.sec.android.app.myfiles.PICK_DATA");
intent.putExtra("CONTENT_TYPE", "*/*");
intent.addCategory(Intent.CATEGORY_DEFAULT);
startActivityForResult(intent, 1);  

但是这段代码在其他设备上不起作用所以我应该怎么做才能在所有设备上打开文件管理器?

4

1 回答 1

2
private void openFile(int  requestCODE) {
    Intent i = new Intent(Intent.ACTION_GET_CONTENT);
    i.setType("*/*");
    startActivityForResult(intent, requestCODE);
}
于 2018-03-23T13:34:25.510 回答