coomar2841 / image-chooser-library

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

onError in Fragment called too soon causing NPE #138

Open fliespl opened 8 years ago

fliespl commented 8 years ago

On some devices returning to fragment with image chooser could lead to NPE (either error or success).

This is because onError is called before activity is available to fragment (getActivity() is still null).

Fatal Exception: java.lang.NullPointerException at xxx.com.SomeFragment.onError(SomeFragment.java:252) at com.kbeanie.imagechooser.api.ImageChooserManager.onError(ImageChooserManager.java:309) at com.kbeanie.imagechooser.threads.ImageProcessorThread.run(ImageProcessorThread.java:57)

coomar2841 commented 8 years ago

In these circumstances, you should be re-initializing the chooser managers. Can you try the sample app and see if they work for your. There's a fragment option which shows how to handle in a fragment.