Mình có 2 code này, nhưng nó chỉ vào luôn file manager mặc định chứ không hiển thị nhiều cái để chọn như hình, làm sao để hiển thị nhiều file manager ạ? Cảm ơn nhiều
public void pickFolder() throws Exception {
try{
startActivityForResult(new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE), PICKFOLDER_REQUEST_CODE);
}catch(Exception e){
toast("File Manager was not found");
}
}
public void pickFile(String mimeType) {
try {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType(mimeType);
intent.addCategory(Intent.CATEGORY_OPENABLE);
// special intent for Samsung file manager
Intent sIntent = new Intent("com.sec.android.app.myfiles.PICK_DATA");
// if you want any file type, you can skip next line
sIntent.putExtra("CONTENT_TYPE", mimeType);
sIntent.addCategory(Intent.CATEGORY_DEFAULT);
Intent chooserIntent;
if (getPackageManager().resolveActivity(sIntent, 0) != null){
// it is device with Samsung file manager
chooserIntent = Intent.createChooser(sIntent, "Open file");
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[] { intent});
} else {
chooserIntent = Intent.createChooser(intent, "Open file");
}
startActivityForResult(chooserIntent, PICKFILE_REQUEST_CODE);
} catch (android.content.ActivityNotFoundException ex) {
toast("File Manager was not found");
}
}