Galaxy nexus Intent.ACTION_PICK bug on Jelly Bean (4.1.1)

放肆的年华 提交于 2019-12-25 05:23:35

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!