android - Pick Image and Pdf using single intent -
i know can use following
- to pick images :intent.settype("image/*");
- to pick pdf files :intent.settype("application/pdf");
so there way can pick single entity either pdf or images through single intent?
here example:
private intent getfilechooserintent() { string[] mimetypes = {"image/*", "application/pdf"}; intent intent = new intent(intent.action_get_content); intent.addcategory(intent.category_openable); if (build.version.sdk_int >= build.version_codes.kitkat) { intent.settype(mimetypes.length == 1 ? mimetypes[0] : "*/*"); if (mimetypes.length > 0) { intent.putextra(intent.extra_mime_types, mimetypes); } } else { string mimetypesstr = ""; (string mimetype : mimetypes) { mimetypesstr += mimetype + "|"; } intent.settype(mimetypesstr.substring(0, mimetypesstr.length() - 1)); } return intent; }
Comments
Post a Comment