pick two images separately in Android

select multiple images from gallery android github
how to display multiple images in imageview in android
how to add multiple images in android studio
capture multiple images from camera android
select multiple images from gallery android library
select multiple images from gallery android kotlin
android custom image gallery with checkbox in grid to select multiple
pick multiple images in android

I'm making and android app where I need two upload images and save them to server.

When I select it from the first button, it is appeared in the second but I need two different images.

photoUpload.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                chooseImage();
            }
        });

        photoUpload2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                chooseImage();
            }
        });
    }

    private void chooseImage() {
        Intent openGalleryIntent = new Intent();
        openGalleryIntent.setType("image/*");
        openGalleryIntent.setAction(Intent.ACTION_GET_CONTENT);
        startActivityForResult(Intent.createChooser(openGalleryIntent, "Select Picture"), GALLERY_REQUEST_CODE);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        if (requestCode == GALLERY_REQUEST_CODE && resultCode == RESULT_OK && data != null && data.getData() != null) {
            Uri uri = data.getData();

            try {
                Bitmap bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), uri);
                imageView.setImageBitmap(bitmap);
                imageView2.setImageBitmap(bitmap);
            } catch (IOException e) {
                e.printStackTrace();
            }

        }

    }

You are getting this because you are setting selected image to imageview 1 and 2. to solve this you can use different request codes or use Boolean variable to differentiate the uploading of image 1 and 2

Define two Boolean variable to differentiate the uploading of image 1 and 2

Boolean first = false, second = false;


      @Override
            public void onClick(View v) {
                first = true;
                chooseImage();
            }
        });

        photoUpload2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
            second = true;
                chooseImage();
            }
        });
    }

    private void chooseImage() {
        Intent openGalleryIntent = new Intent();
        openGalleryIntent.setType("image/*");
        openGalleryIntent.setAction(Intent.ACTION_GET_CONTENT);
        startActivityForResult(Intent.createChooser(openGalleryIntent, "Select Picture"), GALLERY_REQUEST_CODE);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        if (requestCode == GALLERY_REQUEST_CODE && resultCode == RESULT_OK && data != null && data.getData() != null) {
            Uri uri = data.getData();

            try {
                Bitmap bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), uri);
                if(first)
                {
                    imageView.setImageBitmap(bitmap);
                    first = false;
                }else if(second)
                {
                 imageView2.setImageBitmap(bitmap);
                 second = false;
                 }

            } catch (IOException e) {
                e.printStackTrace();
            }

        }

    }

You can use library to select multiple images from Gallery. There are many libraries that are available, one such is https://github.com/ParkSangGwon/TedPicker

Hope this will help you! Happy Coding

How To Pick Multiple Images From Gallery, In this video you will learn to pick multiple images from gallery in Android 18 and above.Duration: 6:15 Posted: May 16, 2019 I have an activity that contains two imageViews. I want to pick image separately from gallery for each one. what should I do in on-Activity-Result to set each image-View background correctly?


You are setting same image to both ImageViews.

Change Your Code to

 photoUpload.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            chooseImage(GALLERY_REQUEST_CODE_1);
        }
    });

    photoUpload2.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            chooseImage(GALLERY_REQUEST_CODE_2);
        }
    });
}

private void chooseImage(int requestCode) {
    Intent openGalleryIntent = new Intent();
    openGalleryIntent.setType("image/*");
    openGalleryIntent.setAction(Intent.ACTION_GET_CONTENT);
    startActivityForResult(Intent.createChooser(openGalleryIntent, "Select Picture"), requestCode);
}

@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == GALLERY_REQUEST_CODE_1 && resultCode == RESULT_OK && data != null && data.getData() != null) {
        Uri uri = data.getData();


        try {
            Bitmap bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), uri);
            imageView.setImageBitmap(bitmap);
        } catch (IOException e) {
            e.printStackTrace();
        }

    }

    if (requestCode == GALLERY_REQUEST_CODE_2 && resultCode == RESULT_OK && data != null && data.getData() != null) {
        Uri uri = data.getData();

        try {
            Bitmap bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), uri);
            imageView2.setImageBitmap(bitmap);
        } catch (IOException e) {
            e.printStackTrace();
        }

    }

}

Android, Apart from his job, he manages Google Developer Group (GDG) - Ahmedabad and has been speaker in various events. He is very much active in� In Android, ImageView class is used to display an image file in application. Image file is easy to use but hard to master in Android, because of the various screen sizes in Android devices. An android is enriched with some of the best UI design widgets that allows us to build good looking and attractive UI based application.


I think you have to set same bitmap in both imageView You should try bellow code

boolean isFromFirstBtn;

photoUpload.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            isFromFirstBtn = true;
            chooseImage();
        }
    });

    photoUpload2.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            isFromFirstBtn = false;
            chooseImage();
        }
    });
}

private void chooseImage() {
    Intent openGalleryIntent = new Intent();
    openGalleryIntent.setType("image/*");
    openGalleryIntent.setAction(Intent.ACTION_GET_CONTENT);
    startActivityForResult(Intent.createChooser(openGalleryIntent, "Select Picture"), GALLERY_REQUEST_CODE);
}

@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == GALLERY_REQUEST_CODE && resultCode == RESULT_OK && data != null && data.getData() != null) {
        Uri uri = data.getData();

        try {
            Bitmap bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), uri);
            if(isFromFirstBtn){
                imageView.setImageBitmap(bitmap);
            }else{
                imageView2.setImageBitmap(bitmap);
            }

        } catch (IOException e) {
            e.printStackTrace();
        }

    }

}

I want to put two photos side by side, but idk howanyone know how , Edit Photos and Videos, Android. Upvote (633) Just select these two in the Photos-app and then choose + on top and select Collage. Google Photos collage got a bit smarter (without announcing?), but not yet very smart. There are nearly as many smartphone models in the world as there are drops of water in the sea. Finding the right one is hard. This interactive product chart, however, simplifies the process


Displaying Images with the Picasso Library, Displaying images is easiest using a third party library such as Picasso from Square dependencies implementation 'com.squareup.picasso:picasso:2.5.2' } To use this snapshot version, you need to add a custom separate Maven repo first: An album preview screen opens with thumbnails of the chosen images and gives you the opportunity to add text and a location to each photo. Select the large plus sign to add more photos to the album. In the left pane, give the new album a name and description, and view the other available options.


Image Combiner, Image Combiner is the simplest and most intuitive app for combining/merging multiple images into one easily shareable picture. Just add a few pictures, sort� Free shipping on orders of $35+ from Target. Read reviews and buy Transformers Generations War for Cybertron Earthrise Voyager WFC-E29 Seeker 2-Pack at Target. Get it today with Same Day Delivery, Order Pickup or Drive Up.


Google Breaks Google Photos Multi-Select Feature, The bug comes into play when selecting multiple photos at once, but fortunately, However, as picked up by Android Police, some users on Reddit have their apps, leaving them forced to select each image individually. Once you’ve selected the image, tap it and then press the “Set wallpaper” button in the top left. A dialog will open asking if you want to set it as the Home screen wall, Lock screen wall, or both. Go ahead and pick whichever one you’re setting. Once the wallpaper has been set, it’ll toss you back into the home screen.