nguyenhoanglam / ImagePicker

A customizable library for selecting images on the device.
Apache License 2.0
599 stars 157 forks source link

Fragment onActivityResult not called, Activity onActivityResult is called #75

Closed okuhlen closed 7 years ago

okuhlen commented 7 years ago

Hi,

I just dicovered this library now. I want to show an image picker, where the user selects their desired image. When implementing this library, I see that the Fragment's onActivityResult is not called - instead, the Activity where the fragment is hosted, gets its onActivityResult. Here is the code on my fragment:

ImagePicker.Builder builder = ImagePicker.with(getActivity()) .setToolbarColor("#212121") .setStatusBarColor("#000000") .setToolbarTextColor("#FFFFFF") .setToolbarIconColor("#FFFFFF") .setProgressBarColor("#4CAF50") .setBackgroundColor("#212121") .setCameraOnly(false) .setMultipleMode(false) .setFolderMode(true) .setShowCamera(true) .setFolderTitle("Albums") .setImageTitle("Galleries") .setDoneTitle("Done") .setMaxSize(10) .setSavePath("HomeNET") .setSelectedImages(imageList) ; builder.start();

Is there a way of making this library call the Fragment's onActivityResult and not the Hosting Activity's onActivityResult??

Thanks.

nguyenhoanglam commented 7 years ago

In Activity's onActivityResult(), remember to add super.onActivityResult(requestCode, resultCode, data) method, so Fragment's onActivityResult() will be called.

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
   // do your logics
    super.onActivityResult(requestCode, resultCode, data);
}
okuhlen commented 7 years ago

Thank you so much for the tip :)

Rainer-Lang commented 7 years ago

@koeks525 If your question is answered - please close this issue.