Loading images efficiently using threads - Java for Android App Development

Hello,
In a component of my application I have an image followed by 4 button choices. When the user presses a button, the other buttons should be disabled and after a 500 ms pause it should inform the user if the choice was correct using a visual cue (such as "want to be a millionaire" where the button blinks with a background color). Afterwards the next image is loaded and proceeds as before.
Thus far I managed to get it working but I feel this approach is partially wrong. As per documentation I'm using an AsyncTask, loading the image in the background and updating the imageView from there. The buttons are disabled from onClick, and using a Handler with a Runnable, I schedule it to run in 500 ms (I also maintain an extra reference to the correct choice with a member Button variable). This only half works as expected because I want another 500 ms of delay when the choice is revealed as correct/incorrect.
What I really want:
1) After the user presses a button, disable the rest
2) Immediately start loading the next image in the background
3) Wait 500 ms to reveal if the choice was correct/incorrect
4) Highlight the correct choice for 500 ms
5) If the image was loaded, display it and continue
Something like this. Instead, what I now do is starting to load the image after the user is informed of his/her choice. Any advice on how I can improve this?

Hi,
Do you have the images locally or you are downloading them from the web? If you have to download images I recommend you a library called "Universal Image Loader for Android"

jdroidsoft said:
Hi,
Do you have the images locally or you are downloading them from the web? If you have to download images I recommend you a library called "Universal Image Loader for Android"
Click to expand...
Click to collapse
I have the images locally in my assets folder.

mmark1 said:
Hello,
In a component of my application I have an image followed by 4 button choices. When the user presses a button, the other buttons should be disabled and after a 500 ms pause it should inform the user if the choice was correct using a visual cue (such as "want to be a millionaire" where the button blinks with a background color). Afterwards the next image is loaded and proceeds as before.
Thus far I managed to get it working but I feel this approach is partially wrong. As per documentation I'm using an AsyncTask, loading the image in the background and updating the imageView from there. The buttons are disabled from onClick, and using a Handler with a Runnable, I schedule it to run in 500 ms (I also maintain an extra reference to the correct choice with a member Button variable). This only half works as expected because I want another 500 ms of delay when the choice is revealed as correct/incorrect.
What I really want:
1) After the user presses a button, disable the rest
2) Immediately start loading the next image in the background
3) Wait 500 ms to reveal if the choice was correct/incorrect
4) Highlight the correct choice for 500 ms
5) If the image was loaded, display it and continue
Something like this. Instead, what I now do is starting to load the image after the user is informed of his/her choice. Any advice on how I can improve this?
Click to expand...
Click to collapse
Correct me if I'm wrong but you outlined what you want to do ? what part do you have a problem with ? and is this homework by any chance ?

deanwray said:
Correct me if I'm wrong but you outlined what you want to do ? what part do you have a problem with ? and is this homework by any chance ?
Click to expand...
Click to collapse
Yes I did but I'm looking on advice on how to accomplish this
Of course it's not homework.

mmark1 said:
Yes I did but I'm looking on advice on how to accomplish this
Of course it's not homework.
Click to expand...
Click to collapse
well I mean what part of what you said you want to do are you having a problem with, cause you outline what you need to do...
and from what you have done, sounds like there is nothing that you're missing ?

Luckily, loading images from the assets directory will only take a couple of milliseconds tops so having your app start loading the image after the user makes a choice will guarantee that the image will be loaded with no jank.

Related

nombCrypt - beta

Hello Everyone,
I just got my 8525 in the mail yesterday and upgraded the boot loader, radio, and WM6. I had a little trouble but in the end, all that I can't get working right is the internet for Cingular. I really appreciate all the hard work everyone puts into this. Here is my thank you, this is my first app so go easy on me.
nomb
nombCrypt
nombCrypt is an encryption program I originally made for the desktop but then decide to port it over. It uses a password you provide and encrypts either a block of text or files using 256bit Rijndael (AES). This level of encryption was given the ok to encrypt Top Secret documents. It can of course decrypt as well. This is for Windows Mobile 6. Please enjoy and every developer of course likes to get back feedback.
Planned/Requested Improvements
Truecrypt like encrypted containers
Implement Encrypted Backups (P)
Get File Encrypt Status Bar Working (P/R) <-- I'm dreading writing the working class :'(
Use Device ID As Salt Option (P)
Randomize Salt More (P)
Add More Encryption Algorithms (P)
Change File Open Dialog To Open Less (R) completed - now initially looks for *.nen (nombCrypt Enc. Files)
Encryption Password Confirmation (R) completed
Clipboard Paste Button (R) completed
Clipboard Clear Button (R) completed
Take Off Start Menu Icon (R) completed
Change Icon (R) completed
Add Exit To The Menu (R) completed
Add Time Out Feature (R) completed - (see page two for details)
Integrate nombCrypt Into WM6 More (P)
I. Encrypt MS Certificate Store (R)
Other Fixes
Improved Text Encryption So The End TextBox Is Opened Less
Added file error checking to the file decryption process
Two screenshots and the cab file are attached.
I hope you guys enjoy...
nomb
Hey! I wanted to do the same thing too! Just that I use my own XOR method (One Time Pad-like) instead. Of all the thing, it works alright, except that I can't get it to do a Copy-Paste. (see here http://forum.xda-developers.com/showthread.php?t=321014)
Also, from what it seems, I would presume that (since you uses AES), the end result would be in 'relatively' binary format (right?), which may not be very program friendly.
I was going to do about the same thing, except that I'll have my end result Base64 encoded, such that I can have them pasted to Notes and have it sycned to outlook. And I have my PC based software to do the job there (if required).
Previously, I used a software called Ccrryyppttoo, which did quite alright, but it seems that my PC is doing some coding, when synced, that makes it goes funny (i.e. cannot be decrypted anymore).
I'll PM you a demo of what I did (in Java web), of which I intended to do it in PPC
With Rijnael the resulting encrypted string/file gets encoded into base64 as well because if it didn't, all the characters wouldn't be represented. You can paste this into notes just fine.
Mine is programmed in c# so there is a clipboard function which works relatively well. If you'd like to help with this your more than welcome to. Or if you want to join your project with mine that would be cool too. I plan to support all major and a lot of minor encryption algorithms that I can find. Plus people were complaining about how the encrypted backup on the ppc should use the device id to encrypt instead of the randomly generated key so I plan to implement that as well.
I'm looking forward to seeing your demo.
nomb
Hmm.. so it is b64 encoded.. niicceee. Hmmm. . I should try out C# soon.
Anyway, there is a suggestion, I'm not sure if you have the library for it. After my symmetric cipher program, I'm in thinking about a asymmetric-public-private key cipher, which people can exchange short messages in secret (e.g. via email, IM, SMS) without the need to exchange the key/password. It is relatively done now, I'll show you the web base version once it is done. It runs on the Java security class, which I'm not sure if C# has those library or not.
The idea is, Alice go to my page, generate a pair of keys. Alice then send Bob her pub key. Bob use pub key, go to my page, encrypt the message. Send it to Alice. Alice decrypt message at my page. No software to install, no secret key exchanged.
Yup c# has the ability to do that built into its cryptography namespace.
That is a cool idea, but instead of having Alice send the key to him. You should just make a db to keep track of the keys and then have him answer a question about Alice or something like that to use the pub key. that way thats even one less step they have to worry about. Or have Alice put in his email address and have your site auto email him the pub key. That would be good too.
But sweet idea, maybe I'll make my program talk to your site.
Have you tried mine yet?
nomb
I dont like the "answer a question" method, as in that case, you might as well use the answer as the password?
Anyway, the emailing the pub key is an idea
I'm not in my own PC yet, can't send it to my phone from this PC. Will try it out later tonight.
hanmin said:
I dont like the "answer a question" method, as in that case, you might as well use the answer as the password?
Click to expand...
Click to collapse
Ya I'm at work and was hungry so I wasn't thinking strait. I don't like that idea either. ^^
I think my next step in mine is to build the background worker class to update the progress bar when you encrypt/decrypt a file.
If you just point your phone to the cab above it will install it for you. You don't need a comp unless u don't have a dataplan.
nomb
I dont have data in my plan.. although O2 gives me 1MB+ a month free.. I'm not using it.
Anyway, I've tested your software, a few comments.
Slightly major problems:
[1] It is not wise to do a 'All folders' and 'All Files' upon browsing (for file to be de/encrypt). People (e.g. me) has gazillion files around and it may take ages to load the list.
[2] You may want to pop up a Window, asking the user to confirm his/her password upon encryption (one of the thing I intended to add on mine )
[3] I'm not able to paste any data onto the 'start text' area. E.g., I have encrypted my stuff, saved it into Notes. Later, I wanted to get it back, I copy the encrypted code from my Notes, and no way of pasting it into the 'Start text'
[4] You already knew this, but, good to have some kind of progress bar to indicate the progress
[5] Hmmm.. on the browsing, there doesn't seems to have a way to find files on my Storage Card's root directory
[6] For security reason, probably it is good for you to add a 'Clear Clipboard' button?
Minor:
[1] I find it annoying that once I had the software installed, it is on my Start menu
[2] You could use a better icon, I just see a black square on my not so bright screen. I can help you on this.
[3] Add an "Exit" on the menus below?
Other possible suggestions:
[1] Have a time out on your software, such that, e.g. if there is no activity on software after a certain amount of time, it will do one/some/all of these (a) close itself (b) clear the password, input, output (c) clear the clipboard
Good suggestions, I'll have those done by tomorrow. I can't play with the storage card aspect yet because I don't have one. :'( Soon though I'm hoping to get a 4gb. And ya, i can't make icons worth any.
Oh, to past it back I always did ctrl+v from the keyboard. But I'll throw a button up there to do that. And I'll make sure to take it off of the start menu.
1 good comment would have been nice. Altho criticism is good.
nomb
Haha.. sorry for the lack of good comments, I was trying to think of something to suggest. But come to think of it my post on top are good comments (e.g. niiiiccceee Base 64 encoded), and the fact that it has the simple string->string encryption.
I did googling a bit, and found these
http://www.entity.cc/ICONS/security-icons.php
http://www.hscripts.com/freeimages/icons/computer/lock-icon.php
http://icons.qarchive.org/
which you may want to use as your icons?
Ya I was just teasing you. The icon I have now I got off of your last link at somepoint I just don't remember when. But I think I will probably use one of the others. But ya, I'll work on those fixes and then attach the updated program. Then once I get those fixes done, I'll work on adding the differnt encryption algorithms and the encrypted backups.
nomb
Did you wrote any backup software before for the PPC? I'm not really sure, but it seems that backup-ing can have a lot of issues. You have the "Copy everything" backup, the PIM only backup, etc. Some backups are ROM-flashing/upgrading friendly, some are not. You can have a backup software all standalone by itself. I would recommend you to have the backup software seperated and have encryption onto it as a plugin. Take a look at PIM-backup, it is very popular here.
Hi,
This is a very interesting thread. Thanks for your efforts so far (is there a donation link anywhere?)
A basic question...I understood that to carry out really secure encryption it would be necessary to write a filter driver that worked within the core ROM Image. Is this not the case?
Can I encrypt the MS certificate store too? The crypto protection on this store could be beefed up...
Once again I am very pleased that this thread has appeared and will be testing your software with interest,
Well done for your work so far,
Sam.
Hey there PianoSam,
First I just want to make it clear I'm not doing this to make money. If anyone donates I want it to be because they like the software. I am at work so PayPal is blocked but I'll put my donation link on the front page later today.
Also, I am going to try and incorporate the encryption as much as possible. If that is a feature you'd like, then after I get all of the previously requested changes done, I'll start on that for you.
And thank you for your kind words.
nomb
***EDITED***
Sorry I didn't answer you question at first.
Question: A basic question...I understood that to carry out really secure encryption it would be necessary to write a filter driver that worked within the core ROM Image. Is this not the case?
Answer: I pondered over this for a little while and I can't think of a reason this would be necessary. However, I've only had my phone for two days. Can you find where you saw that so I can read it as well and maybe gather a little bit on information so I can do some research on the topic? If thats what needs to be done then thats what I'll do but I can't see why. Let me know!
Added another cab with all the fixes I've completed.
nombCrypt-beta.cab <-- On the front page.
I added the donate link.
I added the timeout feature and thought I would make a comment on it.
It is a two minute timeout. Whenever you fucos on a textbox the timer is stopped and when the textbox looses focus, the timer is on. The downside to this is if you were in the middle of typing and set your device down, it wont timeout. I could make it so when you start typing into the textbox it restarts the two minutes and you have two minutes to complete your message but I didn't know if that was a good idea or not.
Also, when you copy, and go to another program to paste it in, you have two minutes before the clipboard is cleared and the program shutdown.
When the encryption program is encrypting something, the timeout is not running. It starts afterwards.
I can tweak this as much as you guys would like, just let me know.
nomb
I've tested your Beta.. niiiiiccceeeeee.. it is gooood. Almost prefect. Few things (OH NO! )
- The "Clear" button doesn't seems to be working. It is suppose to clear the clipboard only? Should you clear off everything as well?
Other requests/suggestion
<rant>
- I'm not sure why I thought I need it.. but it would be good to have a copy function for the "End Text" as well. I thought I may need it one day. Not sure why. It ought to make the screen a bit crowded, I thought.
Anyway, slightly related to the suggestion above, I've just revisited the design I made on my copy-paste-failed PPC attempt, I have this idea which I thought you might want to use it. For my design, I do not have "Start Text" and "End Text", I only have ONE TextField "Message" (and another for the password). The user enter the encrypted/plain text on this "Message". Click on the button "Encrypt" or "Decrypt", the result will then overwrite whatever that is in "Message" TextField.
Example:
(1) "Message"=<plain text>. User key in password, click "Encrypt", "Message"=<encrypted text>.
(2) "Message"=<encrypted text>. User key in password, click "Dencrypt", "Message"=<plain text>.
In such cases, you only need a pair of copy-paste to perform copy-paste on both (in a way) encrypted and plain text.
</rant>
As for the time out issue, I thought the typing-sensitive time out would be a better choice. The moment that you are worried about your data being seen is when you are away from your phone. You can have focus on your TextField but you can be million miles away from your phone. But, you ought to be around to be typing stuff, right?
BTW, I'm also wondering on the working of this time out feature. I thought there ought to be a 'clock' running and when time's up, it will clear the stuff needed to be cleared, right? So, if I were to forget to switch off the application, the timer will not be another running software that drain my battery, right?
Good work.
hanmin said:
- The "Clear" button doesn't seems to be working. It is suppose to clear the clipboard only? Should you clear off everything as well?
Click to expand...
Click to collapse
The "clear" button is in the clipboard row, i think i tagged it on the left, and only clears the clipboard. If you go to menu->reset it will clear everything like your looking for.
hanmin said:
- I'm not sure why I thought I need it.. but it would be good to have a copy function for the "End Text" as well. I thought I may need it one day. Not sure why. It ought to make the screen a bit crowded, I thought.
Click to expand...
Click to collapse
The "Copy" button copies the end text to the clipboard. Not the start text.
hanmin said:
Anyway, slightly related to the suggestion above, I've just revisited the design I made on my copy-paste-failed PPC attempt, I have this idea which I thought you might want to use it. For my design, I do not have "Start Text" and "End Text", I only have ONE TextField "Message" (and another for the password). The user enter the encrypted/plain text on this "Message". Click on the button "Encrypt" or "Decrypt", the result will then overwrite whatever that is in "Message" TextField.
Click to expand...
Click to collapse
I originally had it setup this way, however there was a time when I had wrote a huge paragraph in it and encrypted it, and then found out I had forgot a line. I switched it so this wont happen.
hanmin said:
As for the time out issue, I thought the typing-sensitive time out would be a better choice. The moment that you are worried about your data being seen is when you are away from your phone. You can have focus on your TextField but you can be million miles away from your phone. But, you ought to be around to be typing stuff, right?
Click to expand...
Click to collapse
The timeout I have running in it now, (new version that isn't up yet), is completely off of the user's actions. Whenever you do anything in the program the timer resets. Except for encrypting/decrypting. The timer is off for those functions incase you encrypt a file that takes longer.
hanmin said:
BTW, I'm also wondering on the working of this time out feature. I thought there ought to be a 'clock' running and when time's up, it will clear the stuff needed to be cleared, right? So, if I were to forget to switch off the application, the timer will not be another running software that drain my battery, right?
Click to expand...
Click to collapse
The timeout feature does not clear everything in the program. I have it so it actually completely closes the program. So if you forget to close it and walk away, the program will end so it doesn't drain your battery.
hanmin said:
Good work.
Click to expand...
Click to collapse
Thanks, wait till you see the next version...
nomb
I got the progressbar working for encryption, now for decryption.

MobilMon - File system monitor utility

To the many excellent folks here at xda-developers.com, I'm releasing MobilMon 0.5 for free.
I wrote a simple app that monitors file system access (specifically, file creation, deletion, or modification). This sort of tool can be invaluable when you are trying to figure out what's happening on your system. You can export the findings to a log file.
It's pretty bare bones at this point, but that was somewhat intentional. I wanted to see what folks wanted out of such an app before spending more development time on it.
Check it out, and let me know what you think: http://www.mobilmon.com
wow! thank you! this is pretty much exactly what i was wishing for ever since i started playing around with new apps and such on my phone.
it's a great help for just before a system backup. for example, i have SPB backup set to run every other morning. let's say it runs on Saturday at 5:00am. I install some apps and do some random things from 8:00am to 9:00am. 9:30am, my phone crashes. I reset to 5:00am, and I lost all that stuff i did from 8 to 9. now i know! thanks for this app.
Feature changes
A couple of things I was considering:
1. CSV EXPORT. Would it be better to leave the plain text formatting for easy readability, or format it for CSV export?
2. DIRECTORY. I was originally going to include the ability to change the directory (i.e. something other than just "\") but that would involve some significant work on my part. And, I'm not sure if you'd really want to do that anyway.
3. VIEW FILE READS. As delivered, it monitors file adds, deletes, and changes - not reads. This was done intentionally for performance reasons. Would people want to see all the file reads, even if it bogged the device down?
This is awesome! I haven't seen anything else like it, so I am really happy to see someone from the xda-forums to make this magic!
I think that you should add in the view file reads, but only as an option. Maybe also an option to select which operations you want logged (eg. when I only want to see the files created, and not deleted). Although being able export to CSV would give me the same results, but with some editing.
3. VIEW FILE READS. As delivered, it monitors file adds, deletes, and changes - not reads. This was done intentionally for performance reasons. Would people want to see all the file reads, even if it bogged the device down?
Click to expand...
Click to collapse
Many thanks for the app.
It would be nice to have (even as a separate app) something like mamaaich's file monitor: http://forum.xda-developers.com/showthread.php?t=247425, with ability to start/stop and good frontend - to capture all file activities in the whole system.
It helps a lot to find frequent, unintended system file reads (in most cases - draining batteries)
monitor lost memory
i wonder if you could add some powerful memory mgmt to check where my pda memory is lost and what is the process,application or service which is causing memory leaks or using too much memory. maybe you could draw a graph or monitor memory usage during time for all processes. when i start my pda i have 48% free ram, after a day i am back to 80% without any visible app running.
Thanks!
Thanks
Thanks for the good feedback; I'll look into making it where you can select the types of events to monitor and then go from there.
Good lead on mamaich's program - I wasn't aware of it. I will take a look. I'm all about working smarter, not harder
Hello,
I stumbled over this (admittedly quite old) thread on the search for a windows-mobile version of something like iTunes FolderWatch or iPad ShutterSnatch.
Would it be possible to extend MobiMon such that an action can be triggered once a new file is found? In my case that action would be to start a picture viewer with the newly created file name as a parameter.
Scenario: Send pictures I take with my camera to my Windows Mobile Phone (HTC HD2) via FTP (MochaFTP) through an Ad-Hoc Network directly from the camera (using Eye-Fi). MobiMon would recognize the new file and fire up the picture viewer. This way, the latest picture taken will be shown on HD2's big display right after the shot was taken.
Of course, if there is a more streight-forward way of doing this (like a picture viewer with integrated FTP-Server ) I'd be more than happy to hear about it!
Regards and a happy new year!
Alex
Yes, it's possible.
In regards to your inquiry, it's programmatically possible, but would require a re-write. This has to do with the way things are instantiated. Whether I could afford the time to do it is a different question
1. What is the target OS?
2. Do you have the means and skills to adjust my code and compile it yourself if I just pointed out the changes needed?
allright, heres my question:
is it possible to add (i.e)tray/taskbar icon showing card r/w activity?
I am thinking not exactly about this specific project, but general idea related to it.

Developer with a Marketing question!

I'm a programmer; I don't do Sales, I don't do Marketing LOL
I'm working on an app that has my partner and I debating on pretty much a daily basis. I'll try to explain best as possible without too much detail.
The app takes a pre-loaded database (a "template") from assets folder and loads into the app. Works fine. Thing is, there will be more templates, probably up to 20 for which we want to charge (we're talking small amounts here).
So, here is the debate we're having:
1. Create 20 apps with each having the one template. Easy as hell for me but goes against my programming standards as to why have 20 apps when ONE does the work? NOTE: Does not need any permissions
2. Create one app, ask user for template on startup, download from cloud. A little tougher, but not much. Problem here is that what if they want 2 templates? Or 5? We want to charge for each template. I could do "AppName +2" or "AppName +5"
versions and charge accordingly. NOTE: Max templates a user would have is probably 5.
3. In-app purchasing...I've read about this. Not so easy. You either hide content (and over bloat your app or code a mechanism that allows Joe to have in-app purchase app, but not Julie). Google makes clear note of this in their docs. NOTE: my bloat would be about a 7,000 row database on user's phone.
So, just looking for some other opinions...all comments welcome!
TIA,
Roots
From what I can understand, I think # 1 is the most tried and true method, as most launchers with themes work this way. The upside for you as far as making money is concerned is that there are people who want all their options, whether or not they will ever use them... I have been guilty of it myself with lp+ themes. I've paid for ones I'll never use, because it's there and most apps tend to be in the "impulse buy" price range.
I agree, #1 is your best option, it may require a lot more work as far as deploying goes, but it is the most reliable method.
Interesting! Thank you for your replies.
A little more information...the templates (e.g. database) will probably never change from initial download, so that update is a moot point.
One thing I didn't think about is creating and SAVING 20 keys!!! Yikes. I've lost those before...very bad situation when that happens. Not to mention 20 distinct package names.
One thing I didn't think about is creating and SAVING 20 keys!!! Yikes. I've lost those before...very bad situation when that happens. Not to mention 20 distinct package names.
Click to expand...
Click to collapse
You can sign all packages with the same key.
As of package names, all you need is to change the application package not the code packages. The ADT has a tool for renaming application packages.
1. Create 20 apps with each having the one template. Easy as hell for me but goes against my programming standards as to why have 20 apps when ONE does the work? NOTE: Does not need any permissions
Click to expand...
Click to collapse
Here is my suggestion, although I never tried it:
Create 20 apps for templates with no logic at all.
For each one of these apps:
(1) Put a single template file in the res/raw folder
(2) Create an Activity that doesn't do anything at all (call finish on onCreate).
(3) Set intent-filter for your null activity with android.intent.action.MAIN and your own custom category.
Create 1 main application with all application logic and code but with no templates at all (or just one default template).
(1) Search for installed templates using PackageManager.queryIntentActivities with an Intent that match Intent.ACTION_MAIN and your custom category.
(2) Read templates using Context.createPackageContext, getResources of the created context, getIdentifier to find the id of the template file and openRawResource to actually open it as an InputStream.
There are other methods to share resources, take look at android:sharedUserId.
Interesting concept, but if I read it right, I sill need 20 "dummy" apps to go with the main "driver".
I've got some time to mess with this because I have to implement drag and drop on some ListViews. I might just end-up coding the in-app purchase stuff.
EDIT: LOL, I can't wait till I can afford an iPad and port all my stuff to iOS

[Q] Last read confusion

I'm using the stock nook reader and renate's Library.apk. How can you make sure the last read icon on the top bar corresponds to the last read file in the library?
I am not sure where this icon gets its link. It doesn't seem to always open the last read file.
I've been thinking about asking this question (although I am using the stock reader AND library apps). My "reading now" button is getting really cranky of late. It often just goes to the first page (cover) or sometimes it goes to the first page AND displays a two-option message about the different current reading positions in two Nook readers (!) and which one do I want (generally neither is correct). Right now the only sure way to get to the correct page is to go to the Library screen and select the book from there. So the Nook does remember, but the Reading Now button is not functioning properly.
For a time I had a number of B&N apps disabled (renamed ".bak") and gradually discovered the imponderable connections that seemed to render little things inoperable. I've had to restore quite a few of the apps to running to keep everything functioning except Nook Community (because the constant "nagifications" drove me crazy) but this button behavior has me baffled (as does the reference to two Nook readers!)
I wonder, are you using any sort of "cleaning" app? I am using Clean Master and find it helpful in freeing up memory but I'm beginning to think that some of the data it is throwing out might just contain the info that the button needs to function properly. It certainly messes with Tasker.
The "Last Read" icon on the status bar sends out the intent com.bn.nook.launch.LAST_BOOK
This would normally be handled by Home.apk
If you deleted Home.apk and are using my Library.apk it has its own receiver for that.
Depending on which version Nook software you have it will query
content://com.bn.nook.reader.providers.lastreadingpointprovider/
content://com.bn.nook.reader.common.providers.lastreadingpointprovider/
The LRP database is maintained by the Reader(RMSDK).apk.
Checking for the latest modification gives you the last book read.
My Library.apk sends an intent out to open that book.
Currently Library.apk does not update the order of books displayed in "Last read" unless the refresh button is hit.
Two things to look for if you are having problems:
If you let the battery die and the WiFi is always off the clock time will be wrong.
If you crash or shutdown improperly Reader(RMSDK).apk will not get a chance to update the LRP.
P.S. I just noticed a possible anomaly if you read PDF's in the reader too.
Oh! It just occurred to me one thing.
I remember opening a book that you have been reading already and it opens at page 1.
This was tied to opening the book in different ways.
There are different ways to open a book:
Through the "Last Read" icon and stock Home.apk
Through the stock Library.apk
Through my Library.apk
Through a file manager application
The LRP database is /data/data/com.bn.nook.reader.activities/databases/lastreadingpoint.db
Code:
CREATE TABLE lastreadingpoint
(_id integer primary key autoincrement,
ean text, // file URI
luid text,
offsetrmsdk text, // subfile path fragment
lastupdated long, // Unix milliseconds last read
bookdna int, // always 1?
sync_status int // always 1?
);
ean (which normally might stand for European Article Number, i.e. "UPC") is a URI, not a path.
Code:
sqlite> select ean from lastreadingpoint;
file:///sdcard/Books/aboveall.epub
...
There may be cases where a single book gets different ean's.
If you could look at LRP and see if this is so?
I actually managed to locate that db file on my own (!) and what seemed to be a companion with related information (readerlocal.db). They seemed to be full of junk info (books that had since been removed, etc.) although there were no duplicate entries, which is what I had suspected.
Anyway, I got a little "brave" (i.e., foolhardy) and decided to clean up both files in a parallel way. Then I pushed them back, reset the permissions and rebooted.
Yikes. My Nook is set to go to the B&N Home screen only on reboot. That screen flickered and flashed, never filling in any of the images. I could still use the "N" button to access other parts of the system and they were working fine, but any return to the Home screen via the Back button showed it was still in distress.
So....restore from backup...again.
It seems OK for now. I have noticed that the little "refresh" button in the Library does sometimes seem to go on and on and on without any accomplishment. I have suspected the issue was how I accessed the book-in-progress as you described. Since I sometimes read more than one book at a time, I'm all over the place with how I do things (including a Library icon in my App home screen). I'm going to try being more disciplined for a while and see how it behaves.
nmyshkin said:
I actually managed to locate that db file on my own (!) and what seemed to be a companion with related information (readerlocal.db). They seemed to be full of junk info (books that had since been removed, etc.) although there were no duplicate entries, which is what I had suspected.
Anyway, I got a little "brave" (i.e., foolhardy) and decided to clean up both files in a parallel way. Then I pushed them back, reset the permissions and rebooted.
Yikes. My Nook is set to go to the B&N Home screen only on reboot. That screen flickered and flashed, never filling in any of the images. I could still use the "N" button to access other parts of the system and they were working fine, but any return to the Home screen via the Back button showed it was still in distress.
So....restore from backup...again.
It seems OK for now. I have noticed that the little "refresh" button in the Library does sometimes seem to go on and on and on without any accomplishment. I have suspected the issue was how I accessed the book-in-progress as you described. Since I sometimes read more than one book at a time, I'm all over the place with how I do things (including a Library icon in my App home screen). I'm going to try being more disciplined for a while and see how it behaves.
Click to expand...
Click to collapse
Would it be possible to write an app that simulates opening the last read book from only one of the Library apps and then map that to the last read icon to simplify this whole system?
mergen3107 said:
Guys, if you are concerned about why sometimes the last read option goes to the 1st page, then it was already fixed by our forum users somewhere here. (I could hardly remember and trace where it all started but finally it was successfully solved)
Just install a file this package (internal.db deep in the 'data' folder. You could delete 'system' folder - this is hyphenations dictionary for Russian) through cwm or replace it manually (the zip contains detailed path) and here you go.
Click to expand...
Click to collapse
Now that was an interesting trip! Once I had Google do some translating there were a number of really interesting posts that were (mostly) intelligible. I'd want to compare that modified internal.db file with what's already on my Nook before I did any replacing. A lot of the work from that site is "russified" (not surprisingly) and there may be other changes there not really needed/wanted, but it's a good start.
I noticed in another posting there that someone said there is a related issue with in what state the Nook is connected via USB. Apparently the hypothesis is that if you don't connect while in the Library you stand a good chance of scrambling the "reading now" database entry. I've certainly been hooking up with my Nook in all kinds of states, so if that's correct, no wonder my database file was so messed up!
Installation of the internal.db file from the Russian source will not work. I've tried a side-by-side comparison of the file with the one from my Nook (FW 1.21) and there are differences (beyond the region identifier, which is easily changed). It's not at all clear what changes have been made or from what firmware the modified file came. In any case, it causes havoc when exchanged for the native internal.db
The Russian discussion points to this thread on XDA which approaches (and apparently solves) the problem another way. I'm going to give it a try.
nmyshkin said:
Installation of the internal.db file from the Russian source will not work. I've tried a side-by-side comparison of the file with the one from my Nook (FW 1.21) and there are differences (beyond the region identifier, which is easily changed). It's not at all clear what changes have been made or from what firmware the modified file came. In any case, it causes havoc when exchanged for the native internal.db
The Russian discussion points to this thread on XDA which approaches (and apparently solves) the problem another way. I'm going to give it a try.
Click to expand...
Click to collapse
Do I read this correctly, http://bit.ly/Q7MytN from that thread there should be no problem if renates Library.apk is used exclusively and the stock Library.apk has the bug?

[Q] How to run multiple processes at exactly the same time

I can not publish any code or any logs, because there is no real problem yet. I am a beginner in Android / Java and the OOP concept.
I need to run two processes at exactly the same time in my program. The processes are sound samples and requires played at exactly the same time to be synchronized with each other.
I call the methods on the lines one after the other, which gives me a delay when the first clip starts a few microseconds before. Depending on the hardware this delay will also vary enormously .. how do i run the commands, or call the methods exactly the same time?
I've been looking at adding a delay of the first method by a handler, but I do not want to do this but it does not guarantee accurate synchronization.
I am on track to use AsyncTask, and somehow run these processes simultaneously but in different threads ... I have no idea if I'm on the right track? Can anyone confirm that this is the right way, or provide information about what else I can do? Grateful for all the help I can get. I hope I have not used the wrong terms and that I have given you enough information so that you can understand my question. Thanks in advance.
Having two functions tied to the same event has worked for me in the past.
For example, if you have a play button and you set up two separate functions to run when that button is clicked, they should go at the exact same time. If your play button is pressed, it will fire both functions simultaneously.
Another more advanced approach would be to return the current time code of "sound a" and pause it until the time code of "sound b" reaches the current time of "sound a".
Im Saint said:
Having two functions tied to the same event has worked for me in the past.
For example, if you have a play button and you set up two separate functions to run when that button is clicked, they should go at the exact same time. If your play button is pressed, it will fire both functions simultaneously.
Another more advanced approach would be to return the current time code of "sound a" and pause it until the time code of "sound b" reaches the current time of "sound a".
Click to expand...
Click to collapse
Well "simultaneously" is a big word but you are right, even if one player lags behind the other one, we are talking about microseconds at most. And i doubt that anybody would even notice that.
And to OP:
In java there is a keyword called "synchronized" where one thread awaits the other. I have never used that and so i dont know how to use this. Maybe if you look it up on google it could prove useful to your project. But i actually dont think that you can technically accomplish this "true" synchronization you are thinking of... It is worth a try at least
--------------------
Phone: Nexus 4
OS: rooted Lollipop LRX21T
Bootloader: unlocked
Recovery: TWRP 2.8.2.0
Have you considered buffering? you can buffer samples in some queue and start playing them after a decided delay / samples count, making sure you have samples from all the sources you need to synchronize
Thanks for the replies, any help is much appreciated!
Im Saint said:
Having two functions tied to the same event has worked for me in the past.
For example, if you have a play button and you set up two separate functions to run when that button is clicked, they should go at the exact same time. If your play button is pressed, it will fire both functions simultaneously.
Another more advanced approach would be to return the current time code of "sound a" and pause it until the time code of "sound b" reaches the current time of "sound a".
Click to expand...
Click to collapse
Good to hear, but can it be guaranteed that the function calls are performed exactly the same time? This is very necessary for various reasons.
Masrepus said:
Well "simultaneously" is a big word but you are right, even if one player lags behind the other one, we are talking about microseconds at most. And i doubt that anybody would even notice that.
And to OP:
In java there is a keyword called "synchronized" where one thread awaits the other. I have never used that and so i dont know how to use this. Maybe if you look it up on google it could prove useful to your project. But i actually dont think that you can technically accomplish this "true" synchronization you are thinking of... It is worth a try at least
Click to expand...
Click to collapse
This is what I also want to emphasize. With the greatness of the inner meaning of "simultaneousness", even if that someone would not notice anything, it's a necessity.
I will seriously undermine further the keyword synchronized. This sounds exactly like what I need. I will succeed and reconnect with the results!
pixeltech.dev said:
Have you considered buffering? you can buffer samples in some queue and start playing them after a decided delay / samples count, making sure you have samples from all the sources you need to synchronize
Click to expand...
Click to collapse
I have heard the word buffer before but never truly understood how it works syntactically, nor in Android / Java.
With what kind of content can this be done? All types of media, audio / picture / video? Do you have any keyword to search on or link to an example?
Invisible Algorithm said:
Thanks for the replies, any help is much appreciated!
I have heard the word buffer before but never truly understood how it works syntactically, nor in Android / Java.
With what kind of content can this be done? All types of media, audio / picture / video? Do you have any keyword to search on or link to an example?
Click to expand...
Click to collapse
Buffering is a technique where you first collect enough data (can be represented in any form but is usually done through collections) and once you have enough data you do something with it.
An example can be reading data in bytes form from one source (e.g. network channel), buffering it (storing it in some collection) and writing it to files when buffered data reaches some threshold size

Categories

Resources