1

In my app i need to capture multiple image form camera.

using below code i can capture multiple images but how to get all the images path in callback method

Intent intent = new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA_SECURE);
            startActivity(intent);

Is this possible to complete? please give me suggestion.

Alex Cohn
  • 56,089
  • 9
  • 113
  • 307
John
  • 1,407
  • 7
  • 26
  • 51
  • possible duplicate of [Burst mode camera in Android which can take multiple pictures](http://stackoverflow.com/questions/23149168/burst-mode-camera-in-android-which-can-take-multiple-pictures) – Pedro Oliveira Aug 27 '15 at 09:22
  • possible duplicate of [How to make burst mode available to Camera](http://stackoverflow.com/questions/6889271/how-to-make-burst-mode-available-to-camera) – King of Masses Aug 27 '15 at 09:27
  • It will take multiple images in one short . i want to take different images manually – John Aug 27 '15 at 09:39
  • You can *sort of* call `startActivity(intent)` in a loop. Is that what you are looking for? – Alex Cohn Oct 21 '15 at 08:58

1 Answers1

0

yes , it is possible if I understand the question properly, try the following procedure to resolve your issue

Create model with name Image: create members to save image info like uri, name etc.

public class Image implements Parcelable {

public Uri uri;
public int orientation;

public Image(Uri mUri, int mOrientation) {
    uri = mUri;
    orientation = mOrientation;
}

@Override
public int describeContents() {
    return 0;
}

@Override
public void writeToParcel(Parcel dest, int flags) {
    dest.writeParcelable(this.uri, 0);
    dest.writeInt(this.orientation);
}}

Create Array List to save data in ArrayList

use Camera takePicture method mCamera.takePicture(null, null, mPicture); and use following method to save image:

public void saveImage(Bitmap bitmap, String fileName) {
    String path = MediaStore.Images.Media.insertImage(getActivity().getContentResolver(), bitmap, fileName, null);
    Uri contentUri = Uri.parse(path);
    final Image image = getImageFromContentUri(contentUri);

    getActivity().sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, contentUri));

    getActivity().runOnUiThread(new Runnable() {
        @Override
        public void run() {
            ((TheImagePickerActivity) getActivity()).addImage(image);
        }
    });
}

 @Override
protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);

    ArrayList<Image> list = new ArrayList<>(arraySelectedImages);
    outState.putParcelableArrayList("", list);
}

@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
    super.onRestoreInstanceState(savedInstanceState);
    populateUi(savedInstanceState);
}

private void populateUi(Bundle savedInstanceState) {
    ArrayList<Image> arrayImages = savedInstanceState.getParcelableArrayList("");

    if (arrayImages != null) {
        for (Image image : arrayImages) {
            addImage(image);
        }
    }
}

public boolean addImage(Image image) {

    if (arraySelectedImages == null) {
        arraySelectedImages = new HashSet<>();
    }


        if (arraySelectedImages.add(image)) {
            // Do Something
            return true;

    }

    return false;
}
Abdul Rahman Majeed
  • 1,125
  • 2
  • 10
  • 22