Code example for Camera

Methods: getParametersreleasesetParameterssetPreviewTexturestartPreviewstopPreview

0
            if (mUseCameraInterface) {
                if (mCamera == null) {
                    mCamera = Camera.open();
                } 
                if (value == OFF) {
                    mParams = mCamera.getParameters();
                    mParams.setFlashMode(Camera.Parameters.FLASH_MODE_OFF);
                    mCamera.setParameters(mParams);
                    if (mode != STROBE) {
                        mCamera.stopPreview();
                        mCamera.release();
                        mCamera = null;
                        surfaceCreated = false;
                    } 
                    if (mWakeLock.isHeld())
                        mWakeLock.release();
                } else { 
                    if (!surfaceCreated) {
                        int[] textures = new int[1];
                        // generate one texture pointer and bind it as an 
                        // external texture. 
                        GLES20.glGenTextures(1, textures, 0);
                        GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES,
                                textures[0]);
                        // No mip-mapping with camera source. 
                        GLES20.glTexParameterf(
                                GLES11Ext.GL_TEXTURE_EXTERNAL_OES,
                                GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR);
                        GLES20.glTexParameterf(
                                GLES11Ext.GL_TEXTURE_EXTERNAL_OES,
                                GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);
                        // Clamp to edge is only option. 
                        GLES20.glTexParameteri(
                                GLES11Ext.GL_TEXTURE_EXTERNAL_OES,
                                GL10.GL_TEXTURE_WRAP_S, GL10.GL_CLAMP_TO_EDGE);
                        GLES20.glTexParameteri(
                                GLES11Ext.GL_TEXTURE_EXTERNAL_OES,
                                GL10.GL_TEXTURE_WRAP_T, GL10.GL_CLAMP_TO_EDGE);
 
                        FlashDevice.surfaceTexture = new SurfaceTexture(textures[0]);
                        mCamera.setPreviewTexture(FlashDevice.surfaceTexture);
                        surfaceCreated = true;
                        mCamera.startPreview();
                    } 
                    mParams = mCamera.getParameters();
                    mParams.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH);
                    mCamera.setParameters(mParams);
                    if (!mWakeLock.isHeld()) {  // only get the wakelock if we don't have it already
                        mWakeLock.acquire(); // we don't want to go to sleep while cam is up
                    } 
                } 
            } else { 
Stop searching for code, let great code find you!  Add Codota to your java IDE