我正在使用以下代码打开相机手电筒
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;
}
它使用表面视图,它在许多手机上运行良好但是我不能在galaxy S3上工作。你有过类似的问题吗?任何想法如何让它在S3上工作?
先谢谢