Skip to content Skip to sidebar Skip to footer

How To Use Flash Without Stopping Camera Feed?

I am currently working on a barcode scanning app, which uses the mobile vision api for the majority of processes. I am trying to implement a flash button so that a user may scan in

Solution 1:

i used this code in my custom camera Application.when User clicks the FlashOn Button then Flash will be start.i think this code will help to you.

try this code (OnButton Click) :

privatevoidbtnFlashOnClick() {

if (mCamera != null) {
                // First get the Camera Parameters.
                Camera.Parameters parameters = mCamera.getParameters();

                // set FlashMode to camera parameters.
                parameters.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH);

                // set Parameters Objects to Camera.
                mCamera.setParameters(parameters);

                // Finally, Start the Preview Of a Camera
                mCamera.startPreview(); // this Line is Usefull for MyApp.If you don't need then Remove this Line.
            }
}

this code is works fine in my App..Hope this will helps you...(:

Solution 2:

It really depends what camera api you are using as there are few.

CameraManager has void setTorchMode (String cameraId, boolean enabled) that lets you operate flash regardless of current state of the camera (and without a need to restart one), but it could be overridden by other apps too

Post a Comment for "How To Use Flash Without Stopping Camera Feed?"