i am trying to open recent window which will have only image and pdf selectable
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST);
but in this i can select only image how i can add pdf also
you can do the following using EXTRA_MIME_TYPES (from API 19):
final String[] ACCEPT_MIME_TYPES = {
"application/pdf",
"image/*"
};
Intent intent = new Intent();
intent.setType("*/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
intent.putExtra(Intent.EXTRA_MIME_TYPES, ACCEPT_MIME_TYPES);
startActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST);
UPDATE
There is also another solution but it may or may not work based on users experiences but you can try it to see if it works in your case:
intent.setType("image/*,application/pdf");
However the application that you try to invoke should also supports to MIME types as well
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.