6

In my application, i have to implement native camera activity where i have to launch the camera and take photo.

In detail, my application containing, One TextView (at top) to display activity name and one Button (At bottom) and in Middle Area of the screen, Camera preview should be viewed..When user click on that Button, Snaps should be clicked and display it into Imageview of another activity.

I know that the following approach is used:

Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE );
intent.putExtra( MediaStore.EXTRA_OUTPUT, outputFileUri );
startActivityForResult( intent, 0 );

But this approach if i used then my textview and button view is not displayed.

(Pls note that: I am using Android SDK 1.5 with HTC Hero)

pls help me by suggestion of any article, site, or pdf.

thanx, paresh

Paresh Mayani
  • 127,700
  • 71
  • 241
  • 295

2 Answers2

9

If you are trying to use the native camera, once the native camera is called it will control your view. However if you want to implement your own camera, then such a layout would be possible. Some good examples can be found here:

Goodluck!

ninjasense
  • 13,756
  • 19
  • 75
  • 92
  • Looking that...finally i have to implement the Camera application in a 2nd link way – Paresh Mayani Aug 17 '10 at 05:04
  • thanx for the valuable answer..but let me know what is the maximum size possible to capture with IMAGE_CAPTURE intent ? – Paresh Mayani Aug 17 '10 at 05:05
  • You can get them full size, but you may not be. I ran into the same problem, getting pictures back in a smaller image than they should be I'm guessing. In theory you should be able to get the bitmap via the path you specify on the intent. However I was able to retrieve the larger version via: Uri pic = Uri.parse(data.toURI()); Bitmap bm = Media.getBitmap(getContentResolver(), pic); in the onActivityResult method. Hope this helps. – ninjasense Aug 17 '10 at 05:52
  • this 2nd link way i have implemented in my application...thanx for making my life...really helpful link and ur support – Paresh Mayani Aug 17 '10 at 06:36
  • @PareshMayani Hi Paresh, the second link is broken...can you help me on this? – Wei Keat Dec 01 '16 at 07:11
4

All the instructions are at the JavaDoc of android.hardware.Camera at http://developer.android.com/reference/android/hardware/Camera.html:

  1. Obtain an instance of Camera from open().
  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()).

    The SurfaceHolder is ususally implemented using SurfaceView

David Rabinowitz
  • 29,904
  • 14
  • 93
  • 125