-2

I would like to take a picture in such a way that no user interaction is required and no user interace elements are displayed. In other words, I want to take a picture using a background process. No sound must be made (like the camera shutter when snapping the photo). If possible, it would also be nice if I could set the resolution of the camera rather than resizing the image after it is taken.

All the code samples I've seen use an activity that displays the typical camera app and lets the user manually take the photo.

user
  • 86,916
  • 18
  • 197
  • 190
Johann
  • 27,536
  • 39
  • 165
  • 279
  • Look [Here](http://easyandroidtutorials.blogspot.in/2012/09/capture-image-without-preview-as.html). It might help you in your task. First once camera capture photo in background you need to make mute camera shutter. Check [here.](http://stackoverflow.com/questions/10383083/how-to-mute-camera-shutter-sound-on-android-phone) – Ajay S Jan 09 '13 at 16:13

1 Answers1

3

I think the dev page for Camera outlines the process pretty well. Have you read it?

  1. Obtain an instance of Camera from open(int).
  2. Get existing (default) settings with getParameters().
  3. If necessary, modify the returned Camera.Parameters object and call setParameters(Camera.Parameters).
  4. If desired, call setDisplayOrientation(int).
  5. Important: Pass a fully initialized SurfaceHolder to setPreviewDisplay(SurfaceHolder). Without a surface, the camera will be unable to start the preview.
  6. Important: Call startPreview() to start updating the preview surface. Preview must be started before you can take a picture.
  7. When you want, call takePicture(Camera.ShutterCallback, Camera.PictureCallback, Camera.PictureCallback, Camera.PictureCallback) to capture a photo. Wait for the callbacks to provide the actual image data.
  8. After taking a picture, preview display will have stopped. To take more photos, call startPreview() again first.
  9. Call stopPreview() to stop updating the preview surface.
  10. Important: Call release() to release the camera for use by other applications. Applications should release the camera immediately in onPause() (and re-open() it in onResume()).

While it does mention previews, you can always hide the surface that is used for preview. No user interaction should be necessary.

Samuel
  • 16,923
  • 6
  • 62
  • 75
  • I am looking at the API for Camera but like all the API documents, it doesn't explain the "how-to". Can you paste url of the document you are referring to? Thanks. – Johann Jan 09 '13 at 16:14
  • The link for the Camera API page is above, and that's where I got the ten "how-to" steps above. It's pretty explicit about what you need to do. If you need more than that, use @TGMCians answer because it gives you code. – Samuel Jan 09 '13 at 16:16
  • Sorry, I couldn't see the link because Google Chrome gave it almost the same color as the normal text and without an underline. Thanks. Exactly what I was looking for. – Johann Jan 09 '13 at 16:21