coomar2841 / image-chooser-library

An Easy Image/Video Chooser Library for your Android Apps
646 stars 192 forks source link

"onActivityResult requestCode is different from the type the chooser was initialized with." error #37

Closed cokeby190 closed 10 years ago

cokeby190 commented 10 years ago

Got this error :

"onActivityResult requestCode is different from the type the chooser was initialized with."

on Samsung S3 device,

for requestCode : ChooserType.REQUEST_PICK_PICTURE OR ChooserType.REQUEST_CAPTURE_PICTURE

when trying to take picture / choose from Gallery.

Any idea what could have been causing it?

screen shot 2014-08-12 at 6 24 26 pm

coomar2841 commented 10 years ago

That means that you probably initiated the ChooserManager with a certain type (say ChooseImage), and you are not submitting the data (chooserManager.submit), with a different type (say ChooseVideo).

You can log near the submit call and see what is getting passed as the type..

cokeby190 commented 10 years ago

Any idea if this error comes about when the ChooserManager is reintialized, like in this portion :

if (imageChooserManager == null) { reinitializeImageChooser(); }

or if its from this line instead :

if(requestCode == ChooserType.REQUEST_PICK_PICTURE || requestCode == ChooserType.REQUEST_CAPTURE_PICTURE) {

Because the error came from a particular user, and I never see this error myself. So its tougher to debug. ):

coomar2841 commented 10 years ago

Yeah, reinitialize is the suspected location. You could have the dev settings (Kill Activities) on, and reproduce it reliably on any device.

When an chooserManager is null, you will need to reinitialize it with the proper type, else you will see this error.

cokeby190 commented 10 years ago

I left out the onSaveInstanceState method, my bad. Once I added it in, its fine now (: Thanks for the help. :D

jagatappv commented 9 years ago

Can you tell me how can i use onSaveInstanceState and onRestoreInstanceState with Fragments??

Thanks in advance