Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

registerForActivityResult not called when multiple setMultipleAllowed is true #80

Open
shashankholla opened this issue Oct 30, 2022 · 7 comments
Assignees
Labels
question Further information is requested

Comments

@shashankholla
Copy link

launcher=
              registerForActivityResult(new ActivityResultContracts.StartActivityForResult(),(ActivityResult result)->{
                  if(result.getResultCode()==RESULT_OK){
                      Uri uri=result.getData().getData();
                      // Use the uri to load the image
                  }else if(result.getResultCode()==ImagePicker.RESULT_ERROR){
                      // Use ImagePicker.Companion.getError(result.getData()) to show an error
                  }
              });

launcher.launch(ImagePicker.Companion.with(this)
              .maxResultSize(2000,2000,true)
              .galleryOnly()
              .setMultipleAllowed(true)
              .createIntent());

When I select multiple images and press SELECT in the photo picker, nothing happens. My breakpoint in " if(result.getResultCode()==RESULT_OK){" is not being hit.

@Drjacky Drjacky self-assigned this Oct 31, 2022
@Drjacky Drjacky added the question Further information is requested label Oct 31, 2022
@Drjacky
Copy link
Owner

Drjacky commented Oct 31, 2022

Could you please attach a sample project in Java, to reproduce the issue?

@cson2701
Copy link

cson2701 commented Dec 6, 2022

Same here. The whole registerForActivityResult is not called.

@Drjacky
Copy link
Owner

Drjacky commented Dec 11, 2022

@cson2701 Could you please attach a sample project in Java, to reproduce the issue?

@91coders
Copy link

91coders commented Jan 7, 2023

how to get ActivityResult if we use setMultipleAllowed(true) in JAVA please explain

@Drjacky
Copy link
Owner

Drjacky commented Jan 8, 2023

@91coders Could you please attach a sample project in Java, to reproduce the issue?

@sepidhp
Copy link

sepidhp commented Jul 22, 2024

Hello
I got same error.
I want to select multiple image and then crop them
but after last step, in launcher I got data = null

@sepidhp
Copy link

sepidhp commented Jul 22, 2024

ImagePicker.with(requireActivity())
//...
.provider(ImageProvider.BOTH) //Or bothCameraGallery()
.crop()
.cropFreeStyle()
.bothCameraGallery()
.setMultipleAllowed(true)
.createIntentFromDialog { launcher.launch(it) }

			private val launcher =
	registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {
		if (it.resultCode == Activity.RESULT_OK) {
				try {
					val fileUri = it.data?.data!!
					Log.i(Constants.TAG, "Uri: $fileUri")
					}
				} catch (e: Exception) {
					Log.e(Constants.TAG, "Error: $e")
					Toast.makeText(this.context, "Error: $e", Toast.LENGTH_SHORT).show()
				}
		} else {
			parseError(it)
		}
	}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

5 participants