Hiện tại tôi đang cố gắng chọn loại tệp cụ thể từ thẻ SD hoặc với bất kỳ ứng dụng nào nhưng không thành công, mã của tôi như sau,Chọn docx, doc, rtf, pdf loại tệp từ thẻ SD hoặc với bất kỳ ứng dụng nào trong android
Intent intent;
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT)
intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
else
intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("application/pdf|application/msword|application/vnd.openxmlformats-officedocument.wordprocessingml.document" +
"|application/vnd.openxmlformats-officedocument.wordprocessingml.template" +
"|application/vnd.ms-word.document.macroEnabled.12" +
"|application/vnd.ms-word.template.macroEnabled.12" +
"!application/vnd.ms-word.template.macroEnabled.12|application/rtf");
startActivityForResult(intent, Constants.ImagePicker.REQ_PICK_RESUME);
nhưng nó chỉ chọn mọi loại tệp.
thể trùng lặp của https://stackoverflow.com/questions/33117592/how-to-pick-few-type-of-file-via-intent-in-android – k3b
Có thể trùng lặp [cách chọn vài loại tệp thông qua ý định trong android?] (Https://stackoverflow.com/questions/33117592/how-to-pick-few-type-of-file-via-intent-in -android) – k3b