Joseph Aguilar
Joseph Aguilar

Reputation: 31

Android Studio - Open epub + pdf files from default directory application (Programmatically)

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

Answers (1)

Joseph Aguilar
Joseph Aguilar

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

Related Questions