Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

摄像头无法打开闪光灯,出现空指针 #46

Open
muyexiaogui opened this issue Oct 22, 2019 · 0 comments
Open

摄像头无法打开闪光灯,出现空指针 #46

muyexiaogui opened this issue Oct 22, 2019 · 0 comments

Comments

@muyexiaogui
Copy link

public boolean toggleFlashLight() {
synchronized (syncOp) {
try {
Camera.Parameters parameters = camera.getParameters();
List flashModes = parameters.getSupportedFlashModes();
String flashMode = parameters.getFlashMode();
if (!Camera.Parameters.FLASH_MODE_TORCH.equals(flashMode)) {
if (flashModes.contains(Camera.Parameters.FLASH_MODE_TORCH)) {
parameters.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH);
camera.setParameters(parameters);
return true;
}
} else if (!Camera.Parameters.FLASH_MODE_OFF.equals(flashMode)) {
if (flashModes.contains(Camera.Parameters.FLASH_MODE_OFF)) {
parameters.setFlashMode(Camera.Parameters.FLASH_MODE_OFF);
camera.setParameters(parameters);
return true;
}
}
} catch (Exception e) {
LogTools.d("toggleFlashLight,failed" + e.getMessage());
return false;
}
return false;
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant