Skip to content Skip to sidebar Skip to footer

Fliping The Front Camera To Back Camera In Button Click Using Android

I am facing a problem with flipping the from front to back in android with in the button onClickListener. Here is my code. MainActivity.java package com.example.camerademo; imp

Solution 1:

Finally, i found the solution for the problem. Here is my modification to flip the camera

privatevoidflipcamera() {

        if (camera != null)
        {
            System.out.println("flipcamera");
            camera.stopPreview();
            camera.release();
            camera = null;

        }

        camera = Camera.open(camFront);

        if (camera != null) {
            try {
                camera.setPreviewDisplay(sHolder.getHolder());
                camera.startPreview();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

    }

Thanks guys.

Post a Comment for "Fliping The Front Camera To Back Camera In Button Click Using Android"