ImagePicker
ImagePicker copied to clipboard
How to call launcher in java project?
Can I use this library in java project? if yes then how?
+1
Hi,
Here's what the author replied to me a few months ago :
For any Java projects, you can start image picker like this:
ImagePickerConfig config = new ImagePickerConfig();
config.setMaxSize(3);
Intent intent = ImagePickerLauncher.Companion.createIntent(requireContext(), config);
startActivityForResult(intent, 100);
and handle result like this:
@Override
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 100 && resultCode == Activity.RESULT_OK) {
ArrayList<Image> images = data.getParcelableArrayListExtra(Constants.EXTRA_IMAGES);
if (!images.isEmpty()) {
Glide.with(requireContext())
.load(images.get(0).getUri())
.into(binding.imageView);
}
}
}
In the future, this library will only focus on Kotlin project and I highly recommend you to switch to Kotlin right now.