Tuesday, December 7, 2010

[android-developers] reading Gallery 3D cache

I am working on improving the Gallery 3D program.

I add StorageEventListener so it can detect the state change
if the SD card is pulled out or put in. Below is the code I added in
"onCreate" of Gallery.java

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
mStorageListener = new StorageEventListener() {
@Override
public void onStorageStateChanged(String path, String oldState,
String newState) {
checkStorage();
}
};

if (mStorageManager == null) {
mStorageManager = (StorageManager) getSystemService("storage");
mStorageManager.registerListener(mStorageListener);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Here is what I notice when I do this:
1. Open the Gallery 3D program
2. Put in the SD card, wait until the program finishes building the
cache (indicated by all thumbnails are shown)
3. Pull out the SD card
4. Press back button
5. Kill the program by using "force stop" in the "manage applications"
6. Put in the same SD card again WITHOUT any modification (adding,
deleting, moving, etc)
7. Wait until the "preparing SD card" message is gone
8. Open the Gallery 3D program again
9. Voila! The program reads the cache and can load the thumbnails in a
very quick speed.
(note: the SD card contains about 3 Gigabytes of images and videos)

But, if I don't do "force stop", when I put in the same SD card again
(without modification),
the program will rebuild the cache again.

Is there any way to read the cache directly after I put in the SD card
again without killing the application?

Thank you.

Sincerely,
Alex Chandra

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment