问题
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);
来源:https://stackoverflow.com/questions/14354081/galaxy-nexus-intent-action-pick-bug-on-jelly-bean-4-1-1