0

I've found a very frustrating bug on galaxy nexus. I start az ACTION_PICK activity to select image from, after starting it, the device shows the gallery, and immediately return and call onActivityResult, so I can't pick an image. It's only on galaxy nexus after update to Jelly Bean.

Intent photoPickerIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(photoPickerIntent, RequestCodeCollection.GALLERY_IMAGE_SELECT);

I tested image picking with Instagram, and it worked well. What could be the trick?

UPDATE

I removed all code from onActivityResult() and I tried to remove overriding onActivityResult(). It not works. I checked how Instagram works. They use an ACTION_GET_CONTENT and a chooser. To create chooser is very important, because in this way user can't select a default source. If I don't create a chooser for every picking, I can select default source (like gallery, filemanager etc.), and after selecting the default the problem comes back.

Intent photoPickerIntent = new Intent(Intent. ACTION_GET_CONTENT , android.provider.MediaStore.Images.Media. EXTERNAL_CONTENT_URI);
photoPickerIntent.setType( "image/*" );
startActivityForResult(Intent. createChooser(photoPickerIntent, "Select Picture"),RequestCodeCollection. GALLERY_IMAGE_SELECT);

I removed all code from onActivityResult() and I tried to remove overriding onActivityResult(). It not works. I checked how Instagram works. They use an ACTION_GET_CONTENT and a chooser. To create chooser is very important, because in this way user can't select a default source. If I don't create a chooser for every picking, I can select default source (like gallery, filemanager etc.), and after selecting the default the problem comes back.

Intent photoPickerIntent = new Intent(Intent. ACTION_GET_CONTENT , android.provider.MediaStore.Images.Media. EXTERNAL_CONTENT_URI);
photoPickerIntent.setType( "image/*" );
startActivityForResult(Intent. createChooser(photoPickerIntent, "Select Picture"),RequestCodeCollection. GALLERY_IMAGE_SELECT);
casperOne
  • 73,706
  • 19
  • 184
  • 253
ba-res-ba
  • 150
  • 1
  • 9
  • R u starting activity for result from tabactivity? As I found similar issue when I start activity for result from tabactivity on any version of Android. – Sandip Jadhav Jan 16 '13 at 08:43
  • Instead of sending image in result when you finish activity, save image bitmap in a static variable whatever you are doing processing after you get image put it in onResume() Also I think you need to maintain a flag. – Sandip Jadhav Jan 16 '13 at 08:47
  • Yeah, I know that issue, but it's a single activity, and only has problem on galaxy nexus 4.1.1. On HTC flyer, Sensation, Galaxy S3 works perfectly. – ba-res-ba Jan 16 '13 at 08:48
  • I see, but I can't even select an image. It shows gallery view only for ~1 second. – ba-res-ba Jan 16 '13 at 08:51
  • Remove all the code from onActivityResult() and then try again. – Sandip Jadhav Jan 16 '13 at 09:15

0 Answers0