简体   繁体   English

Android Studio-通过默认目录应用程序以编程方式打开epub + pdf文件

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

如何打开默认文件管理器应用程序,该应用程序允许您通过Intent以编程方式选择文件,但扩展名为.epub.pdf

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. 所示代码是意图的声明,您必须开始打开默认的文件管理器应用程序,该应用程序允许您选择文件,但扩展名为.epub.pdf ,我希望它会有用。

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! 让我知道你的想法!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM