How To Open Kindle Ebook From Android?
I'm trying to launch the Amazon Kindle app from my android application but based on a specific book that the user clicks. I'm able to determine the books available and which book t
Solution 1:
First we need to set the intent to an ACTION_VIEW
intent.
Then we need to define an Uri
for the data which is actually a link that looks something like: kindle://book/?action=open&book_id=AMZNID0/B000FC1GHO/0/, where in this case the section B000FC1GHO corresponds to the ID of the book.
Finally we can then start the activity. In my case I had to set some flags on the intent to launch a new activity.
The code I'm using is as follows:
if(intent.getAction().contains("BOOK_ACTION_"))
{
Log.w("LOG", "We have a book selected");
bookID = intent.getAction().substring(12);
Log.w("LOG", bookID);
Intentreadbook=newIntent(Intent.ACTION_VIEW);
readbook.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Urifile= Uri.parse("kindle://book/?action=open&book_id=AMZNID0/" + bookID + "/0/");
readbook.setData(file);
context.startActivity(readbook);
}
I'm overriding the onReceive
method in this case so that I can perform some additional steps on each book. Presumably because I'm just setting an ACTION_VIEW
intent this could have been handles in the other class that does the onClickListener
for the imageview
that holds the book I want.
Post a Comment for "How To Open Kindle Ebook From Android?"