ImagePicker icon indicating copy to clipboard operation
ImagePicker copied to clipboard

How to call launcher in java project?

Open aerocube-tech opened this issue 3 years ago • 2 comments

Can I use this library in java project? if yes then how?

aerocube-tech avatar Jul 18 '22 10:07 aerocube-tech

+1

yasdeveloper avatar Sep 30 '22 11:09 yasdeveloper

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.

Pocus76 avatar Oct 14 '22 10:10 Pocus76