1

I know that the above functionality can be achieved by creating custom camera by overriding camera class. But what i want to know is that, when i click a button, I will open default device camera to open using Camera intent, Once it open the default camera i need to capture multiple image by continuously clicking on take photo button (as we usually do on camera app) and store in the memory without returning to the app activity, once i done with the capturing multiple images i need to return to my app and then i need to upload those captured pictures to Webservice. Is there any possibility for doing this? Please help on this. Thanks

Rotomac17
  • 239
  • 3
  • 16
  • you can't do that with the default camera class – Gusman Aug 29 '15 at 05:14
  • Yes. Somewhat I guessed that we cant perform above kind of work in android default camera. But beyond my knowledge there may be some possibility. thats why i have posted my query here. If anybody comes across like this please help on this. @Gusman. Thanks for your immediate response. – Rotomac17 Aug 29 '15 at 05:18
  • np, we're here to help :), the default camera is intended for taking a picture and end it's life cycle, because that you don't have any chance to do it with the default. Maybe you can take a video instead of a photo and then get the frames from it? – Gusman Aug 29 '15 at 05:19

2 Answers2

2

Instead of issuing an image capture intent with startActivityForResult(), Android allows your app to simply launch the default camera app (you can find it via PackageManager) with startActivity(). User will not be limited to capturing photos, though. They may switch cameras, take videos, view gallery, share.

When (if) the user presses "back", your app will resume. It will not receive onActivityResult() callback, but it will have a chance to scan the captured photos and decide what to do with them.

Alex Cohn
  • 56,089
  • 9
  • 113
  • 307
  • This is the best approach .Rather than implementing Camera API ,it is better to use the existing camera application – Farmaan Elahi Apr 06 '18 at 06:08
  • Hi, Alex Cohn. We can use default camera app, how can we know that what no of photos user have clicked and how to get that file's path to upload those photos on server? – Kinal Mer Jun 21 '18 at 05:57
1

To Achieve this, You will have to create your own embedded camera in your application rather than using a intent to open a camera application installed on your device. You can use the latest Camera API 2.

Here is the basic example which I customized for my applications need. And also there are 2 sample applications you can get straight from Android studio's sample projects.

Using this, you can Save all the images on the call back Method and also have a additional button or on Back Button Pressed, you can start the Uploading of those images.

This is the callback method,

/**
 * This a callback object for the {@link ImageReader}. "onImageAvailable" will be called when a
 * still image is ready to be saved.
 */
private final ImageReader.OnImageAvailableListener mOnImageAvailableListener
        = new ImageReader.OnImageAvailableListener() {

    @Override
    public void onImageAvailable(ImageReader reader) {

        //mBackgroundHandler.post(new ImageSaver(reader.acquireNextImage(), mFile));
        // Do what ever you like, Original code does is, it save the image using a handler.
    }

};

Only Cavity here is, you will not get the Advanced features provided by a dedicated camera application and you do not want to write a advanced camera application, which is a different project and also beware of different manufacturer support Samsung S5 with Lollipop had some issue, But the code works after some minor changes to the code.

diyoda_
  • 5,274
  • 8
  • 57
  • 89