Search code examples
androidandroid-cameraandroid-camera-intent

How to replace MediaStore.ACTION_IMAGE_CAPTURE with a custom camera activity?


I have an app that uses a MediaStore.ACTION_IMAGE_CAPTURE intent to take a photo, and then returns the photo to an OnActivityResult function.

However, I'd like to replace this with my own custom camera activity, and integrate it into the app.

Are there any guides out there on doing this? I am new to android and I've never made a camera activity before, or hooked one up to other parts of an app.

Thanks for any help


Solution

  • There's a basic guide to this on the Android developer pages:

    http://developer.android.com/guide/topics/media/camera.html#custom-camera

    In short, you have to build the UI you want for capturing an image; usually you'll want a viewfinder SurfaceView or TextureView, and then some controls.

    Then, you'll need to create a Camera object, connect your viewfinder to it, and then start up preview. Once that's going, you can take a picture, change settings such as zoom, and so on.

    See the guide for details and example code.

    In Android L, there's a whole new Camera2 API, which is more powerful, but for simple use cases the older camera API will work just fine.