开发者

Android Intent for EPUB

开发者 https://www.devze.com 2023-02-03 17:08 出处:网络
Say I want to do the following: Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(path, \"application/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 fil开发者_StackOverflow中文版ter 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消