Aug 10, 2010
I have an Android application that allows the user to select a photo that has already been taken. Once the user selects a photo, I grab the URI information for that photo, use that information to create a bitmap, and then I set the bitmap in an ImageView. This all works perfectly fine.I then give the user the option to select the picture for viewing. When the user chooses to view the picture, I launch an ACTION_VIEW intent, passing the URI data. Intent intent = new Intent(Intent.ACTION_VIEW, pictureUri);startActivity(intent);As you can see, this is very simple code, nothing special going on. The problem is that, when I run this code on my Droid running Android 2.1, about 6 or 7 times out of 10, the application will display the correct picture. But the other 3 or 4 times, I get shown the wrong picture. Also, each time the wrong picture is shown, its always the same incorrect picture being shown. The fact that I see the right picture the majority of the time leads me to believe everything I'm doing in code is fine, so can anyone tell me if you have seen this problem before, and better yet, is there a solution? Here is the exact sequence that I observe on my Droid when I run this (Note: Image URI is already saved before I start the Activity):
View 1 Replies
- I choose "View Photo" in the Activity
- When things work, I get taken to the gallery and shown image 74
- Each time things do not work, I get shown image 82
Keep in mind that when I start the Activity with the URI already saved (retrieved from database), I set an ImageView based on the URI data in onCreate(), and the Image being shown in the ImageView is ALWAYS the correct image. It's not until I actually decide to view the image using ACTION_VIEW that I see odd behavior. And I know it's not something specific about these 2 photos. I observed this behavior using other photos in the past, and got the same behavior.