Closed cmonfortep closed 11 years ago
Hi @culebrins .
Recently, I had added this functionality. You should be able to recreate the ImageChooserManager if it's null by passing in a string.
imageChooserManager = new ImageChooserManager(this, chooserType, "myfolder", true);
imageChooserManager.setImageChooserListener(this);
imageChooserManager.reinitialize(filePath);
The filePath here is a string, which you would get while calling ImageChooserManager.choose().
For picking up images/videos, this would be null, but you can use the same code to re-intialize the object nevertheless.
Also, do have a look at the sample app if you need to go into more details. Let me know if it works, and then I can close this issue.
Hi @coomar2841
Everything it's ok now, thanks for the info.
Just one comment.
Into your sample code, you have:
if(imageChooserManager==null){ reinitializeImageChooser(); } private void reinitializeImageChooser() { imageChooserManager = new ImageChooserManager(this, chooserType, "myfolder", false); imageChooserManager.setImageChooserListener(this); imageChooserManager.reinitialize(filePathChoose); }
If the activity is destroyed, you also lose the "chooserType" variable, so the value type of your new imageChooserManager instance is different than the value on the previous instance.
I've solved this issue adding a line to reinitialize also de chooserType variable depending the case.
if(imageChooserManager==null){ chooserType=ChooserType.REQUEST_PICK_PICTURE; reinitializeImageChooser(); }
Thank you again for you fast response.
Right. That I should change it to handle activity's lifecycle. Would make that change soon. Now closing this issue.
Hi,
I would like to notify a problem I've found using imagechooser library.
After opening the gallery and going back to the main activity, android sometimes has killed the activity, so I get null pointer exception into "onActivityResult" because imageChooserManager=null.
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == RESULT_OK && (requestCode == ChooserType.REQUEST_PICK_PICTURE || requestCode == ChooserType.REQUEST_CAPTURE_PICTURE)) { imageChooserManager.submit(requestCode, data); } }
Could you explain how to solve this problem into the section "usage:"? It happens because all is controlled inside de object ImageChooserManager, how could I restore this object if the activity is killed?
Thanks.