Android: PDF files hidden despite setting the MIME type

Faux Pas picture Faux Pas · Apr 11, 2016 · Viewed 8.1k times · Source

This is my Intent:

Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("text/* , application/pdf, image/*");

But, when the file explorer shows up, the PDF files are grayed out i.e., un-choosable. Is there any workaround for this?

Answer

mohit picture mohit · Apr 15, 2016

If you are using minimum Android version 19 then you can do this below way

Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent .setType("*/*");
String[] mimeTypes = {"image/*", "application/pdf"};
intent .putExtra(Intent.EXTRA_MIME_TYPES, mimeTypes);