Reputation: 31
How to open default file manager app that let you choose a file but only with extension .epub
or .pdf
programatically via Intent?
Upvotes: 1
Views: 1244
Reputation: 31
The code shown is the declaration of the intent that you have to start for opening the default file manager app that let you choose a file but only with extension .epub
or .pdf
, I hope it will be useful.
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("application/epub+zip");
String[] mimetypes = {"application/epub+zip", "application/pdf"};
intent.putExtra(Intent.EXTRA_MIME_TYPES, mimetypes);
startActivityForResult(intent,PICKFILE_RESULT_CODE);
It is a mix of solutions I found that work so maybe it is redundant. Let me know what you think!
Upvotes: 2