Playing with Otter Intents and Book Shortcuts - Kindle Fire General

Unlike most, I've found myself actually liking the content-oriented otter launcher on stock. But, being a geek, I'm never satisfied so I was playing around with GoLauncher and ADW to see if I could get the best of both worlds. This is what I've uncovered so far.
To launch a specific part of Otter, such as the book library, you need to send the following type of intent:
Code:
Action: com.amazon.kindle.otter.action.SHOW_BOOKS
Category: android.intent.category.HOME
The valid actions are:
Code:
com.amazon.kindle.otter.action.SHOW_BOOKS
com.amazon.kindle.otter.action.SHOW_NEWS
com.amazon.kindle.otter.action.SHOW_APPS
com.amazon.kindle.otter.action.SHOW_DOCS
com.amazon.kindle.otter.action.SHOW_MUSIC
com.amazon.kindle.otter.action.SHOW_VIDEO
com.amazon.kindle.otter.action.SHOW_WEB
If you want to open a specific book, then you send an intent like this:
Code:
Action: android.intent.action.VIEW
Data: kindle://book/?action=open&book_id=AMZNID0%2FB002WB0XW0%2F0%2F
All that you want to change in that data string is the escaped book_id field. '%2F' just means '/', so you can see it's really just 'AMZNID0/(Book ID)/0/'. You can extract the book's ID from any Amazon Kindle product page (go to Manage your Kindle on Amazon.com). So, the book ID in this example is: B002WB0XW0 and the URL of the product page is http://www.amazon.com/dp/B002WB0XW0 (plus some useless SEO keywords and tracking cruft I omitted).
Launching documents is very similar, but I assume each document's id is user specific. To see what it is, fire-up logcat ("adb logcat ActivityManager *:S") and look for a message like this:
Code:
D/ActivityManager( 1452): Starting: Intent { act=android.intent.action.VIEW dat=
kindle://book/?action=open&book_id=AMZNID0%2FAEMEN728GNT2MXUF3VMENDMEY4SDV5AZ%2F
4%2F flg=0x10000000 cmp=com.amazon.kindle/.UpgradePage } from pid 3749
As for how to launch intents, several launchers let you do this. Sadly, Amazon gutted Settings.apk, so we're left with no provider for android.intent.action.pick_activity (ditto for shortcuts and folders). Therefore, we need an app like QCustomShortcut that will allow us to construct a custom intent shortcut, then directly add the icon to the launcher without going through the activities or shortcut menus. Sadly, that's not listed as compatible with the Fire, so you have to install it on another Android device and sideload the APK (which is kept under /mnt/asec, not /data/app, BTW).
In the end, I decided to return to Otter, but figured I could save someone a bit of trouble or hopefully even spark some ideas by posting this. It's all pretty basic stuff, but finding/launching intents and what-not took me a bit to sort through this evening so I suppose there may be others on this neophytic ledge between being a newb and a guru that I keep finding myself on.

Hi izomiac,
I'm interested in what you said. I'm creating an android that can open any kind of documents, including ebooks.
Unfortunately I could not see the kind of information you show in my logcat.
You said :
Launching documents is very similar, but I assume each document's id is user specific.
Click to expand...
Click to collapse
Could you give me an example to how open an ebook not downloaded by the amazon kindle app?
Really thank you for your post, it helps me a lot.

I don't think the Kindle app can directly open Documents/Books that haven't been downloaded. When I just tried that the Kindle App (for ICS) stayed on the splash screen and never loaded anything. I suspect Amazon uses some sort of push service rather than an intent to start an automatic download.
For logcat, what I did was run the logcat command using ADB, then launch the document I wanted to see the ID for on the Kindle using the stock launcher.

izomiac said:
To launch a specific part of Otter, such as the book library, you need to send the following type of intent:
Code:
Action: com.amazon.kindle.otter.action.SHOW_BOOKS
Category: android.intent.category.HOME
Click to expand...
Click to collapse
Hello,
I know this is an old post, but I am trying to get this to work on my HDX. Looking at both the Otter manifest, and the logcat, it seems not a lot has changed (except that now you can install qCustomSHortcut).
However, when I try to create a shortcut to my books library, I get a permission denied error. When I test the shortcut, the output says that this
Code:
com.amazon.SHOW_CONTENT_LIBRARY
action is required. Any thoughts?
The direct book link works well. Thank you.
~Leko

Related

Detect Package Launch

I am working on an application and I need to be able to have a service that can detect when applications are opened, and take action based on that.
I have looked everywhere, and have not found a way to do so. I have read documentation on broadcast receivers, intent handlers, I found nothing.
I did however, find an app that can do so. App Protector. It allows password protecting certain applications.
Can anybody please point me in the right direction?
Thanks!
this is actually a very good question. a BroadcastReciever only gets Intents directed at it, and wouldnt see Intents for other classes and Packages.
ill be very interested to know the answer
killersnowman said:
this is actually a very good question. a BroadcastReciever only gets Intents directed at it, and wouldnt see Intents for other classes and Packages.
ill be very interested to know the answer
Click to expand...
Click to collapse
Well I was looking for a BroadcastReceiver that was sent out by the system to indicate that an app was opened, but I did not come across anything.
this isnt possible.. to be able to monitor all intents would make android extremely insecure
http://groups.google.com/group/android-developers/browse_thread/thread/54ddc9d36a24d77b
but there are ways to know when an application is launched. you just have to be creative.
this will give you a list of all the applications running.
Code:
ActivityManager am = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
List<ActivityManager.RunningAppProcessInfo> runningAppProcessInfo = am.getRunningAppProcesses();
however to know when an app is launched you would need a timed loop and then check between versions of the List to see if there is a new app. this would suck the juice and be inneficient
AppProtector seem to access the eventlog. maybe you could have a ContentObserver attached to the event log
http://developer.android.com/reference/android/util/EventLog.html
http://developer.android.com/reference/android/database/ContentObserver.html
killersnowman said:
this isnt possible.. to be able to monitor all intents would make android extremely insecure
http://groups.google.com/group/android-developers/browse_thread/thread/54ddc9d36a24d77b
but there are ways to know when an application is launched. you just have to be creative.
this will give you a list of all the applications running.
Code:
ActivityManager am = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
List<ActivityManager.RunningAppProcessInfo> runningAppProcessInfo = am.getRunningAppProcesses();
however to know when an app is launched you would need a timed loop and then check between versions of the List to see if there is a new app. this would suck the juice and be inneficient
AppProtector seem to access the eventlog. maybe you could have a ContentObserver attached to the event log
http://developer.android.com/reference/android/util/EventLog.html
http://developer.android.com/reference/android/database/ContentObserver.html
Click to expand...
Click to collapse
Interesting.
I also found this:
Code:
String str = ((ActivityManager.RunningTaskInfo)this.am.getRunningTasks(1).get(0)).topActivity.getPackageName();
It's one of the things App Protector uses
It starts a new intent, pointing to their application, and passing the parameters of the package you tried to run
Take a look at Tasker it can defiantly do this.
rujelus22 said:
Take a look at Tasker it can defiantly do this.
Click to expand...
Click to collapse
He doesn't want it for scripting, but for use in his own program.
From something awesome

[Q] How to export Notes and Highlights on Touch? Cppy and Paste?

Hello,
Thanks in advance. I searched the forum and elsewhere for these answers.
Can one export Notes and Highlights with a rooted Nook Touch. If so, how and which app should one download? Which are best?
If one puts Kindle app on a Nook Touch, does one get the functionality of exporting notes that I believe the Kindle app has?
Is there an a reader app that allows for Copying/Pasting/exporting? There is this unanswered thread that I think covers the same topic or similar:
http://forum.xda-developers.com/showthread.php?t=1180368
Much to my dismay, I just discovered that I can not export or backup Notes and Highlights that I create on a Nook Touch. I wonder what % don't realize this when they buy the device.
I do not think that "Nook For PC" does any of this as it only syncs bookmarks across devices:
http://www.barnesandnoble.com/u/nook-for-pc/379002322/
Once again thank you
I've been able to export from moon reader plus on my nook color - if this app works on nook touch it's the best solution I've found.
any solution found?
I want to root my nook, but I don't want to lose my highlights...!!!
I have been on the same quest for a few days now. I have not found a particularly good solution, but I do have a way to preserve highlighting.
When you use the kindle app on android and sideload a book in .mobi format (i.e. you place the .mobi file in /sdcard/kindle folder), and then make highlights or notes, it creates a .mbp file in the same directory. You can then move the .mobi and .mbp file into other kindle apps (other device, pc, etc), and your notes and highlights are preserved.
If I could find a way to get the .mbp file in /sdcard/kindle to automatically sync to the appropriate PC folder, it would be nearly perfect.
The advantage of .mobi files have over .epub is that .epub standard does not seem to include annotations. At the moment, you are somewhat confined to the Amazon ecosystem, but for now, this seems the best solution I've found so far.
---------- Post added at 10:18 AM ---------- Previous post was at 10:04 AM ----------
I have been on the same quest for a few days now. I have not found a particularly good solution, but I do have a way to preserve highlighting.
When you use the kindle app on android and sideload a book in .mobi format (i.e. you place the .mobi file in /sdcard/kindle folder), and then make highlights or notes, it creates a .mbp file in the same directory. You can then move the .mobi and .mbp file into other kindle apps (other device, pc, etc), and your notes and highlights are preserved.
If I could find a way to get the .mbp file in /sdcard/kindle to automatically sync to the appropriate PC folder, it would be nearly perfect.
The advantage of .mobi files have over .epub is that .epub standard does not seem to include annotations. At the moment, you are somewhat confined to the Amazon ecosystem, but for now, this seems the best solution I've found so far.
Any updates
Does anybody have any updates on this? I've been looking at how to save my highlights and notes because I want to update to 1.1.
I noticed that Calibre is testing saving notes from the Kobo reader. I think this would be the best way if they ever do it for the NST. However, that would be a long term solution because I don't see them doing it within the next month or so.
Any help on this would be greatly appreciated. Thanks,
The first post in this thread shows how to backup highlights and annotations. http://forum.xda-developers.com/showthread.php?t=1346748 I haven't tried it yet but I will check back when I do it.
this is a a feature really needed...anybody working on it??
Here's a direct link to the post referenced above. Highlights and notes are stored in databases.
http://forum.xda-developers.com/showpost.php?p=20069243&postcount=5
I haven't tested it yet.
Anyone interested in exploring -- you may want to look into some of the apps in the Android Market that allow for viewing and editing databases on a rooted device:
https://market.android.com/search?q=root+database+viewer&c=apps
Please post any findings!
MJ
mjj777 said:
Please post any findings!
Click to expand...
Click to collapse
It’s easy to write SQL script, but it’ll be few manual steps - not for everybody.
I’m not good enough yet to write GUI app, but it looks like nice and easy one to start with.
The problem is B&N doesn’t provide any API to work with nook specific features, like display book thumbnail, get books in library, get books on shelf, etc.
Once this framework is available, “assembling” apps should be piece of cake.
Manual Solution...
Besides backing up highlights and annotations (mentioned above) http://forum.xda-developers.com/showpost.php?p=20069243&postcount=5
I am following this thread that just started on somebody asking a possible way to do this automatically to dropbox or something similar. Which I think would be awesome! http://forum.xda-developers.com/showthread.php?t=1676579. However, this really doesn't solve the issue of easily reviewing highlights and annotations or exporting them to excel or word for a more pleasant viewing experience.
In the meantime as I am reading I have my iPhone open and I am writing down comments and passages and then marking the page number. I am doing this in the Onenote app which can be synced to my computer.
It makes reading not as fun when you have to go to a different device and type something in. However, I am guaranteed not to loose it, and it stays organized in a onenote folder I named "books" and section is the books title. Putting the page number also allows me to later go back and go to that specific page for further details and it is my understanding it should also match with the paper-bound version page number.
I find it amazing there is not an easier way. However, I have heard rumors the backing up a annotations and highlights might/could happen in Calibre. I think they began trying it with the Kobo reader. I think this would be ideal.
CoolReader can highlight, take notes and export.
The only problem is that it doesnt have DRM so it cannot read
books with DRM (purchased or rented books).
--
Is there any news on this side?
to me would be enough to having the possibility to share via mail.
does anyone knows if an app for android would work for this and if it feasible ?
Ok
i've just create a very basic app that export the highlithed text to an txt file inside the sd card.
source code is here (i started yesterday with android, so it's crappy).
https://github.com/esseti/NookTouchExporter
here the apk https://github.com/esseti/NookTouchExporter/tree/master/bin
it requires root permission.
feedbacks/collaborations anything is welcomed.
Off-hand, you might want to use a constructor for Annotation instead of setting things:
Code:
public class Annotation
{
private String book;
private String hltext;
public Annotation(String book, String htltext)
{
this.book = book;
this.hltext = hltext;
}
}
question
Hi, first, thanks for placing the apk and second, how do I use it?
I already install, I gave root permission, but nothing happens when you touch the icon
thanks
I forgot to subscribe to the thread. i made some changes, now it should have a button.
apk is here https://github.com/esseti/NookTouchExporter/tree/master/out/production/NookExporter
esseti said:
I forgot to subscribe to the thread. i made some changes, now it should have a button.
apk is here https://github.com/esseti/NookTouchExporter/tree/master/out/production/NookExporter
Click to expand...
Click to collapse
I've just tried this (md5sum: fc31f1bd16a95ebd5c41823cb9bbc57d) on my 1.2.1 UK Nook rooted with NookManager, and it has some problems.
When I start it, it asks for root via SuperUser and I grant it root permissions permanently. However, the attempt to copy annotations.db fails:
Code:
I/ActivityManager( 788): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x14000000 cmp=it.stefanotranquillini.nookexporter/.TestDatabaseActivity }
I/System.out(24021): books 1here we are
W/System.err(24021): io ex
W/System.err(24021): java.io.FileNotFoundException: /data/data/com.bn.nook.reader.activities/databases/annotations.db
E/TC ( 1035): KPICollector: 1368871897842 ActivityManager background {"component":"com.harasoft.relaunch/.AllApplications"}
E/TC ( 1035): KPICollector: 1368871897875 ActivityManager foreground {"component":"it.stefanotranquillini.nookexporter/.TestDatabaseActivity"}
Needless to say, the file does exist:
# ls -l /data/data/com.bn.nook.reader.activities/databases/annotations.db
-rw-rw---- app_0 app_0 11264 2013-05-07 15:57 annotations.db
Click to expand...
Click to collapse
I think you probably need to build a command line (e.g. su /system/xbin/cp /data/data/com.bn.nook.reader.activities/databases/annotations.db blahblah/databases.db) then exec() it. exec()ing su doesn't, AFAICS, give your app the power to do anything it likes as root. Chainfire wrote a nice doc: http://su.chainfire.eu/.
If I use an adb shell to manually copy the file over, it seems to export OK. I'd suggest, though, dumping all the columns so that adding import functionality later is possible.
cowbutt said:
I've just tried this (md5sum: fc31f1bd16a95ebd5c41823cb9bbc57d) on my 1.2.1 UK Nook rooted with NookManager, and it has some problems.
When I start it, it asks for root via SuperUser and I grant it root permissions permanently. However, the attempt to copy annotations.db fails:
Code:
I/ActivityManager( 788): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x14000000 cmp=it.stefanotranquillini.nookexporter/.TestDatabaseActivity }
I/System.out(24021): books 1here we are
W/System.err(24021): io ex
W/System.err(24021): java.io.FileNotFoundException: /data/data/com.bn.nook.reader.activities/databases/annotations.db
E/TC ( 1035): KPICollector: 1368871897842 ActivityManager background {"component":"com.harasoft.relaunch/.AllApplications"}
E/TC ( 1035): KPICollector: 1368871897875 ActivityManager foreground {"component":"it.stefanotranquillini.nookexporter/.TestDatabaseActivity"}
Needless to say, the file does exist:
I think you probably need to build a command line (e.g. su /system/xbin/cp /data/data/com.bn.nook.reader.activities/databases/annotations.db blahblah/databases.db) then exec() it. exec()ing su doesn't, AFAICS, give your app the power to do anything it likes as root. Chainfire wrote a nice doc: http://su.chainfire.eu/.
If I use an adb shell to manually copy the file over, it seems to export OK. I'd suggest, though, dumping all the columns so that adding import functionality later is possible.
Click to expand...
Click to collapse
i've no idea why it fails .
anyway i'll take a look later on. if you want code is on github and you can change it and submit as a patch (or whatever they called it), then i'll merge it.
Hello,
I haven't found a solution to the original question posted on this forum but I would like to share something that I think most Kindle users will benefit from.
Amazon has made it possible for Kindle users to make notes and highlights on their favorite passages or selection and these can be accessed again on their site. However, it can take up time and be difficult to obtain sometimes.
There is an iOS app that will be released this November 2013 called Snippefy that will make it easier for Kindle users to read and share their notes and highlights all in one place. They will also be able to export these to Evernote, Dropbox and email. I'm not able to post the link to the site here but basically it's at "snippefy dot com"
I just wanted to share this with all of you as you might find it useful.
Thanks!
Two ereaders I've found that do a good job of allowing for annotations, and have good export options are Moon+ Reader (version 1.6.5b) and Mantano Reader (version 2.2.12).
They are no longer being developed in a way that supports the Android 2.1 platform, which is what the Nook runs on, so the versions I listed above are the most recent versions that will work on the Nook, you'll have to get the old APKs and sideload them if you want to use that. Their controls and interface are amazing in my opinion, perhaps Moon+Reader 1.6.5b > Mantano Reader 2.2.13, however, the display is in my opinion quite low quality and unacceptable for extended reading.
A better option to keep your eye on is Page Turner (https://play.google.com/store/apps/details?id=net.nightwhistler.pageturner.ads&hl=en]). The developer is very active and mindful that a large portion of the user base uses the Nook ST, and so continues to have features support the Android 2.1 platform. The current beta version which will be released in the next weeks has just added support for highlighting, annotating and bookmarks. The plan for the next version is to allow for simple export process of these additions, so keep an eye on it.

[Q] Forcing a refresh of the stock library app

Is there any way to force the stock library app to scan for new/deleted side-loaded books? Dropsync seems popular around here (though I'm using FolderSync with Google Drive), but I can't find a good way to force the stock library app to acknowledge that it's selection of books have changed. I'm forced to resort to rebooting, or plugging and unplugging the device from a computer. I'm willing to resort to crazy hacks that involve tasker, sending intents, and/or root shells scripts, if that helps.
If I remember correctly, the stock Library app relies on Mediascanner.
Mediascanner on Andorid 2.1 wasn't that great and also doesn't allow simple poking to get it to read directories.
I gave up on that a long time ago.
I use my own Library.apk replacement (in signature).
There's a button at the top for refresh.
Thank you Renate NST - you've pointed me in the right direction yet again. The media scanner was the answer.
Code:
am broadcast -a android.intent.action.BOOT_COMPLETED -c android.intent.category.HOME -n com.android.providers.media/.MediaScannerReceiver
Running that in adb shell forces an immediate re-scan of media. I figured that out using the info I found in:
Code:
./aapt dump xmltree MediaProvider.apk AndroidManifest.xml
I'll probably use Tasker to fire this intent on some simple trigger, like wifi disconnect. FolderSync has some Tasker integration if I buy the full version, so maybe that will work as well.
EDIT: This intent appears to be more specific, shouldn't have any side-effects, and still works:
Code:
am broadcast -a android.intent.action.MEDIA_MOUNTED -n com.android.providers.media/.MediaScannerReceiver

Shortcut to Books Library...

Thank you all for the wonderful support you are giving this device. While am an expert tinkerer, I do not have the time or knowledge necessary to take this device to the level I desire without the help you all afford.
So, having said that, I recieved my refurb unit (rollback was not an option when I contacted customer support, and 13.4.5.3 broke many things for me, The native Kindle app was among them.), I was able to toss twrp on it and update to 13.4.5.2, root it, and trick it to near perfection. Yet, I hate having to jump through hoops to get to my amazon books, so I played around with adb logcat and xda searches, and stumbled upon this...
http://forum.xda-developers.com/showthread.php?t=1479858
izomiac found a way to make a link on the older Kindles. I tried it, and though it looks like there are only a few changes, it does not work out of the box.
I would like to create a link to my books library as well as links to individual books.
Code:
Action: com.amazon.kindle.otter.action.SHOW_BOOKS
Category: android.intent.category.HOME
fails with an error of
Code:
Action: com.amazon.kindle.otter.action.SHOW_BOOKS
Category: android.intent.category.HOME requires com.amazon.SHOW_CONTENT_LIBRARY
I am using QCustomShortcut to try this as launching the intent from shell did not work either.
Does anyone have any suggestions? I asked over in iziomac's thread too, but it is really old, and I did not know if anyone would even see it.
Incidentally, his code for linking to individual books works incredibly. That is an android level intent, so there is less which could go wrong.
Code:
android.intent.action.VIEW
Data: kindle://book/?action=open&book_id=AMZNID0/<bookid>/0/
He explains pretty clearly how to get the book id as well.
izomiac said:
All that you want to change in that data string is the escaped book_id field. You can extract the book's ID from any Amazon Kindle product page (go to Manage your Kindle on Amazon.com). So, the book ID in this example is: B002WB0XW0 and the URL of the product page is http://www.amazon.com/dp/B002WB0XW0 (plus some useless SEO keywords and tracking cruft I omitted).
Click to expand...
Click to collapse
Again, this is all Izomiac's work, not mine.
~Leko
Could you not edit the APK and manually add the missing permission it requires?
https://developer.android.com/guide/topics/security/permissions.html
Thanks. When using a shortcut created with that app, who calls for the intent?
Sent from my KFTHWI using Tapatalk

Question: How to set an intent to launch Temblast Reader in Relaunch?

Hey guys, I have a question. I'm sure somebody out there has done this. I am making Rooted NST's for my friends as gifts, and I think it would be really easy for them to be able to use relaunch to open the .epub format books I have included for them. The best reader app I have found is @Renate NST's temblast reader app. It works with the page turning buttons, and in conjunction with @nmyshkin's NoIR app that he made, it makes for a seriously long battery life while reading. I gave my best friend a rooted NST for his birthday (beginning of August). He has read an entire book, and still hasn't charged it. Thanks for that, guys.
Anyway, what I'm trying to do is be able to use Relaunch to open .epub books. I've included a screenshot of the menu that has the ability to set intentions or even to open an application based on the filetype of the file selected. However, temblast reader does not show on the list of possible apps to launch. I tried using Titanium Backup to move temblast reader to system, but still to no avail. Anyone who knows better how to set an intent, and perhaps knows the language needed to do this would probably be much better suited to helping.
Thank you so much in advanced.
PS: That intent that is typed in the line for .epub files is my own feeble attempt at trying to get temblast reader to run as a system app. Please ignore that. :cyclops:
I'm not sure about Relaunch, but this should work fine:
Code:
# am start -a android.intent.action.VIEW -d file:///sdcard/Books/progit.epub
I typed it in like you said, and it didn't work. Maybe it's just not meant to be done on Relaunch.
Here's what it looked like when I tried to launch an .epub file.
Black screen.
I also thought maybe it was because my epub files are in My Files/Books so I added that in, and it didn't change anything.
I really appreciate your help and effort in this. Perhaps you know of an intent simply for "Reading Now"? I could use that in a different application.
Do you actually have that book "Pro Git"?
If you don't, there's no chance that it will be opened.
"Last Book" was actually a broadcast originally. Try:
Code:
# am broadcast -a com.bn.nook.launch.LAST_BOOK

Categories

Resources