Search code examples
javaandroidandroid-camera2

Take picture using camera2 in android


In the days of the "old" camera-API I used the simple code:

        Intent imageIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
        imageIntent.putExtra(MediaStore.EXTRA_OUTPUT, uriSavedImage);
        startActivityForResult(imageIntent, CAPTURE_IMAGE);

and it worked great.

Now with camera2 the sample code is about 1035 lines of code - android-camera2Basic example.

Isn't there a simpler way of just taking a picture with the new camera2-API ?


Solution

  • In the days of the "old" camera-API I used the simple code:

    That code has nothing to do with the "'old' camera-API" (android.hardware.Camera).

    Isn't there a simpler way of just taking a picture with the new camera2-API ?

    The code in your question works just fine... within the limits of the camera apps that you might be linking to.

    Implementing android.hardware.Camera was somewhat easier than android.hardware.camera2.*, but not by a lot, and both APIs are terribly complicated.