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

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?

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);

Related

Opening image in Gallery app programatically shows low resolution

I download and save an image on button click in my app. This works fine. If I view this image via the Gallery app (or any other way) it looks fine.
However, if I try to open the image with:
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(imageFile), "image/*");
startActivity(intent);
It prompts me what app I want to open the file with (Gallery or Photos). If I select Gallery, the image opens but is very low resolution. As the photo contains a lot of text, it makes it so you can't zoom in and read. If I select "Photos", it looks fine.
Is there anything I can do to make it work fine in Gallery?
So I was saving the image with no extension. As it was opening in Gallery I figured it knew it was an image, but as soon as I added ".jpeg" to the file name, it showed in correct resolution. Strange bug, figured I'd update just in case someone else was hoping to find an answer here at some point.

Displaying Images in Gallery and sharing them

My application is capable of capturing images and saving them (in the public Pictures directory, retrieved by Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).
Now, I want to be able to display those images in the system's gallery application. In order to achieve that, I create an Intent like this (filePath is a String containing the image's path):
Intent viewIntent = new Intent();
viewIntent.setAction(Intent.ACTION_VIEW);
Uri uri = Uri.fromFile(new File(filePath));
viewIntent.setDataAndType(uri, "image/jpeg");
startActivity(Intent.createChooser(viewIntent, null));
Displaying an image this way works perfectly fine, but the gallery's Share functionality doesn't seem to work:
When I press the Share-button, I get to choose the app I want to share to; but once I select it, nothing happens, as if the target application does not receive any data.
Is there any explanation why this behaviour occurs and how it can be fixed?
Edit: I used Intent Intercept to capture the Intent created by the Gallery/Photos app:

Android Gallery App - unable to select image due to no input

I am currently working on an application that lets users upload pictures by selecting them in the android gallery. This seems to work across most android phones however there are some issues with certain ones. On an LG Optimus Elite when the gallery is loaded to select the image it does not accept any touch. I can see the pictures and gallery however I cannot not select anything. It is almost as if it is frozen. There is nothing I can do at this point, not even press go back button.
Here is my code that launches the gallery:
Intent i = new Intent(Intent.ACTION_GET_CONTENT, null);
i.setType("image/*");
i.putExtra("return-data", true);
i.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
startActivityForResult(i, REQUEST_GALLERY_PICTURE);
Any input would be greatly appreciated.
Thank You
Use this
to open gallery
Intent i = new Intent(Intent.ACTION_PICK,android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(i, RESULT_LOAD_IMAGE);

Android display image in image viewer

I'd like to show a png in the built-in image viewer.
Here is my code:
Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(path)), "image/png");
startActivity(intent);
It displays a msgbox with a list which contains more than 10 different applications that can display the image.
How to limit the msgbox to two or three applications (the most significant if
possible)?
I belive you cant do that, the point of the Intent is to let the user have to freedom to decide what to use to open it.

modified android ACTION_VIEW intent

I execute the following code:
Uri uri =
Uri.withAppendedPath(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
imageIdStr); Intent intent = new
Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
intent.setData(uri);
activity.startActivity(intent);
which opens the image viewer activity but I don't want to see the navigation arrows as well as the items in the menu. I only want the zoom controls. Is it possible to have it like that ?
That depends on the application that's actually displaying the image. On Android 2.0 and older, it's probably the Gallery app. On many Android 2.1+ apps, it's probably CoolIris' gallery. If the user has one of the many gallery apps from the market installed, it's up to those apps. I highly doubt there's a standardized extra to control that.
If you're really concerned about what the image display looks like, then you should handle that yourself. If you're really just trying to display an image (and maybe add pinch-zoom support?), it's a reasonable scope.

Categories

Resources