Code example for Camera

Methods: lockreleasesetDisplayOrientationsetPreviewDisplaystartPreviewstopPreview

0
            // released and we need to open the camera. 
            mCameraDevice = Camera.open(1);
        } 
 
        if (mPreviewing) {
            mCameraDevice.stopPreview();
            mPreviewing = false;
        } 
        try { 
            mCameraDevice.setPreviewDisplay(holder);
        } catch (IOException e) {
            e.printStackTrace();
        } 
 
        mCameraDevice.setDisplayOrientation(90);
        // Util.setCameraDisplayOrientation(this, mCameraId, mCameraDevice); 
        // setCameraParameters(); 
 
        try { 
            mCameraDevice.startPreview();
            mPreviewing = true;
        } catch (Throwable ex) {
            closeCamera(); 
            throw new RuntimeException("startPreview failed", ex);
        } 
 
        initializeRecording(); 
    } 
 
    private void closeCamera() { 
        Log.v(TAG, "closeCamera");
        if (mCameraDevice == null) {
            Log.d(TAG, "already stopped.");
            return; 
        } 
        // If we don't lock the camera, release() will fail. 
        mCameraDevice.lock();
        mCameraDevice.release();
        mCameraDevice = null;
        mPreviewing = false;
    } 
 
    @Override