当前位置: 动力学知识库 > 问答 > 编程问答 >

Android Intent for EPUB

问题描述:

Say I want to do the following:

Intent intent = new Intent(Intent.ACTION_VIEW);

intent.setDataAndType(path, "application/epub");

At the moment I'm having a tough time finding an app out there that has a filter setup for epub, and was wondering if anyone has any ideas.

My intent is to load an epub file in an external application, which will be initiated from mine. Tried using Aldiko, but it doesn't seem to have any filters setup for this.

网友答案:

Try

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(path, "application/epub+zip"); 

seemed to work for me. The mime type is not official (yet) http://en.wikipedia.org/wiki/EPUB this worked for me with Aldiko.

网友答案:

You may use an Intent to start a specific application using Context.startActivity(Intent). It throws "ActivityNotFoundException" exception which you can catch and try start another application that supports epub, and so on.

You can target some of the most popular apps before showing an error to the user, and so obviously, your app will have to mention a pre-requisite for at-least one of these apps.

Of-course this is a ugly hack and you should avoid doing this, but this may work for you till you find a better solution, ie apps like Aldiko introduce a epub filter.

网友答案:

It doesn't seem like an external app exists for my purposes.

So, my solution is to write my own ereader to parse EPUB files for my unique needs.

网友答案:

Google play books opens application/epub+zip. But not application/epub. It will fail though if they have not activated uploads in google play books settings.

分享给朋友:
您可能感兴趣的文章:
随机阅读: