1

I know that this question was asked already but I haven't found a solid solution for this I worked on many examples but none of them was working that properly. I found one example from this post.

I used the commonsware source code. It was working fine, but when I am using the code my camera is getting opened in the horizontal layout instead of vertical layout.

I got to know that there are two ways of doing so. One through the Camera API and another through intent thing. For capturing single snapshot I used the intent part and it was working quite fine.

Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
                intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
                intent.setType("image/*");
startActivityForResult(Intent.createChooser(intent,"Select Picture"), RESULT_LOAD_IMAGE);

But this keeps on clicking the images, My requirement is I need it to stop clicking the images after 5 photos.

I am not getting any clue on how to achieve this.

Community
  • 1
  • 1
anand
  • 1,711
  • 2
  • 24
  • 59

2 Answers2

0

@Chris Hutchinson has posted this answer at How to take multiple photos before dismissing camera intent?

I discovered through the SDK documentation that there's an alternative intent action for the device camera that launches the camera in still image mode and does not exit until the user is finished with the activity:

   Intent intent = new Intent(
   MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA);
   this.startActivity(intent);

Coupled with a ContentObserver this was exactly what I needed to accomplish.

Community
  • 1
  • 1
Dharmendra Pratap Singh
  • 1,332
  • 1
  • 11
  • 22
  • "that there's an alternative intent action for the device camera that launches the camera in still image mode and does not exit until the user is finished with the activity" -- the behavior of any third-party application with respect to this `Intent` action is up to the implementer of the third-party application, not you. There is no requirement that any camera app "not exit until the user is finished with the activity". So, you *may* get that behavior with some camera apps, but not all. – CommonsWare Oct 01 '14 at 10:36
  • You can use ContentObserver to track how many photos are clicked, if the count of photos are 5 then you can launch your activity above it. – Dharmendra Pratap Singh Oct 01 '14 at 13:37
  • There is no requirement for a camera application to store its images someplace that you can readily monitor via a `ContentObserver`, particularly for images returned via `ACTION_IMAGE_CAPTURE` or `INTENT_ACTION_STILL_IMAGE_CAMERA`. For example, there is no requirement that a camera app have such images indexed by `MediaStore`, preferring to leave that up to the developer who is invoking the camera. – CommonsWare Oct 01 '14 at 14:54
0

But this keeps on clicking the images

The behavior of any third-party application with respect to this Intent action and extra is up to the implementer of that application.

My requirement is I need it to stop clicking the images after 5 photos.

You have no means of forcing the world's camera app developers to stop taking images after five, or to force the user to take five.

I am not getting any clue on how to achieve this.

Use the Camera API. Note that writing camera applications that work across all devices is very difficult.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491