/**
* 调用系统选择文件,支持pdf doc docx image
*
* @param activity
*/
public static void systemFile(Activity activity) {
try {
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
String pdf = "application/pdf";
String doc = "application/msword";
String docx = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
String image1 = "image/png";
String image2 = "image/jpeg";
String[] mimeTypes = {doc, docx, pdf, image1,image2};
intent.putExtra(Intent.EXTRA_MIME_TYPES,mimeTypes);
intent.setType("*/*");
intent.addCategory(Intent.CATEGORY_OPENABLE);
activity.startActivityForResult(intent, REQUEST_CHOOSEFILE);
} catch (ActivityNotFoundException e) {
e.printStackTrace();
}
}
记得用这个
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
https://stackoverflow.com/questions/1698050/multiple-mime-types-in-android