Android Zxing 添加闪光灯功能
zxing
ZXing ("Zebra Crossing") barcode scanning library for Java, Android
项目地址:https://gitcode.com/gh_mirrors/zx/zxing

·
最近做了关于二维码解析的模块
选用的是google的开源工程Zxing
在Zxing 添加闪光灯功能 如下:
在 com.xxx.xxx.Zxing.camera 包下的CameraManager类中
添加代码:
//openLight 是开启闪光灯
//offLight 是关闭闪光灯
public void openLight(){
if (camera != null) {
parameter = camera.getParameters();
parameter.setFlashMode(Parameters.FLASH_MODE_TORCH);
camera.setParameters(parameter);
}
}
public void offLight(){
if (camera != null) {
parameter = camera.getParameters();
parameter.setFlashMode(Parameters.FLASH_MODE_OFF);
camera.setParameters(parameter);
}
}
在你需要调用闪光灯的类中
//开闪光灯
CameraManager.get().openLight();
// 关闪光灯
CameraManager.get().offLight();
闪光灯的功能就加进来了
希望对大家有用




ZXing ("Zebra Crossing") barcode scanning library for Java, Android
最近提交(Master分支:18 天前 )
0a14de90
1 个月前
f2813890
Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 5.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v4...v5)
---
updated-dependencies:
- dependency-name: actions/checkout
dependency-version: '5'
dependency-type: direct:production
update-type: version-update:semver-major
...
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> 1 个月前
更多推荐
所有评论(0)