How to speed up image viewing with android "Cooliris" gallery?

518 views Asked by At

I'm running 2.3 on a Nexus S (but writing code against 2.2), and it takes forever for an image to display in the default cooliris gallery. This is how I am attempting to display an image:

Uri imageIdentifier = getImageUriOnFilesystem();
Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
intent.setDataAndType(imageIdentifier, "image/jpeg");
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Activity.this.startActivity(intent);

In the end, it takes 5-10 seconds for the gallery to go from a black screen to showing my image which is absurdly long and makes me think I'm doing something wrong. Is there a better way to display an image in the gallery without requiring a different gallery be installed?

1

There are 1 answers

0
AudioBubble On

You can add new images to the media index as you acquire them, which may may reduce the startup time of the gallery application.

Intent i = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
i.setData(imageIdentifier));
sendBroadcast(i);