-1

I am in trouble displaying customized phone gallery.

At first, I need to show images folders in gridview (such as phone gallery), and on selecting any of the folder, it must show the pictures inside it and should allow multiple selection, so that I can pick multiple pictures.

Is it achievable?

If yes, how to do that?

Narendra Singh
  • 3,990
  • 5
  • 37
  • 78

2 Answers2

0

To open gallery :

//open gallery to choose image

    private void captureImage() {

        // Create intent to Open Image applications like Gallery, Google Photos
        Intent galleryIntent = new Intent(Intent.ACTION_PICK,
                android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
        // Start the Intent
        startActivityForResult(galleryIntent, RESULT_LOAD_IMG);

    }

When the image is selected from the gallery , the following function is invoked , implement it to save the image selected .

// When Image is selected from Gallery
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        try {
            // When an Image is picked
            if (requestCode == RESULT_LOAD_IMG && resultCode == RESULT_OK
                    && null != data) {
                // Get the Image from data

                Uri selectedImage = data.getData();
                String[] filePathColumn = { MediaStore.Images.Media.DATA };

                // Get the cursor
                Cursor cursor = getContentResolver().query(selectedImage,
                        filePathColumn, null, null, null);
                // Move to first row
                cursor.moveToFirst();

                int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
                imgPath = cursor.getString(columnIndex);
                cursor.close();

                // Get the Image's file name
                String fileNameSegments[] = imgPath.split("/");
                fileName = fileNameSegments[fileNameSegments.length - 1];

                // successfully selected the image
                // launching upload activity

                tvCapturePicture.setText(fileName);

            } else {
                Toast.makeText(this, "You haven't picked any Image",
                        Toast.LENGTH_LONG).show();
            }
        } catch (Exception e) {
            Toast.makeText(this, "Something went wrong ,please try again , ",
                    Toast.LENGTH_LONG).show();
        }

    }
Divyanshu Jimmy
  • 2,542
  • 5
  • 32
  • 48
  • It doesn't seem to contain the folders as the parent of their corresponding images, i.e, first screen must show the parent folders (as that in phone gallery), and on selecting any one of them, must display its images to be allowed for multiple selection. – Narendra Singh Mar 18 '15 at 09:36
0

as per your requirement follow this tutorial it will give ideas..

http://www.technotalkative.com/android-select-multiple-photos-from-gallery/