Fliping the Front Camera to Back Camera in Button Click using android

前端 未结 1 1254
余生分开走
余生分开走 2021-01-24 06:28

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 <

相关标签:
1条回答
  • 2021-01-24 06:48

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

    private void flipcamera() {
    
            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.

    0 讨论(0)
提交回复
热议问题