Camera flashlight on galaxy s3

74 views Asked by At

I am using following code to turn on camera flashlight

public Flashlight(SurfaceView preview, Context context){
    this.preview = preview;
    this.context = context;
    mHolder = preview.getHolder();
    mHolder.addCallback(this);
    mCamera = Camera.open();
    cameraOpened = true;
    try {
        mCamera.setPreviewDisplay(mHolder);
    }catch (Exception e){
        e.printStackTrace();
    }
    params = mCamera.getParameters();
    mCamera.startPreview();
}
private void turnOnFlashlight(){
    params.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH);
    mCamera.setParameters(params);
}
private void turnOffFlashlight(){
    params.setFlashMode(Camera.Parameters.FLASH_MODE_OFF);
    mCamera.setParameters(params);
}
@Override
public void surfaceCreated(SurfaceHolder holder) {
    mHolder = holder;
    try {
        mCamera.setPreviewDisplay(mHolder);
    }catch(Exception e){
        e.printStackTrace();
    }
}

@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {

}

@Override
public void surfaceDestroyed(SurfaceHolder holder) {
    mHolder = null;
}

it uses surface view and it works great on many phones however I cant get it to work on galaxy S3. Have you experienced similary problems? Any ideas how to get it working on S3?

Thanks in forward

0

There are 0 answers