How do I open the “front camera” on the Android platform?

前端 未结 9 2358
挽巷
挽巷 2020-11-22 15:00

More generally, if a device has more than one embedded camera, is there a way to initialize one of them in particular?

I didn\'t find it in Android reference documen

9条回答
  •  生来不讨喜
    2020-11-22 15:39

    public void surfaceCreated(SurfaceHolder holder) {
        try {
            mCamera = Camera.open();
            mCamera.setDisplayOrientation(90);
            mCamera.setPreviewDisplay(holder);
    
            Camera.Parameters p = mCamera.getParameters();
            p.set("camera-id",2);
            mCamera.setParameters(p);   
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    

提交回复
热议问题