谷歌官方库, 使用CameraX
和ML Kit
工具包实现的, 支持二维码/条形码
的单扫/多扫
功能, 速度也是非常快.
使用Zxing
Zbar
结合 扫描, 默认1s
切换一次Zxing
或Zbar
.
- 具有
Zxing
所有特性 - 具有
Zbar
所有特性 - 支持
生成二维码
- 支持
从图片扫码
, 三层方法识别. - api 16+
- zxing 3.3.3, 3.4需要api 24+
- zbar 快, 支持的格式少.
- zxing 慢, 支持的格式多.
ScanActivity.start(this)
ScanActivity.onResult(requestCode, resultCode, data)
RCode.syncEncodeQRCode("内容", 500)
RCode.scanPicture(bitmap)
class AppScanFragment : ScanFragment() {
override fun getLayoutId(): Int {
return R.layout.fragment_app_scan
}
}
xml
文件中,包含qr_code_scan_layout
即可,其他元素可自行添加.
<include layout="@layout/qr_code_scan_layout" />
ScanActivity.start(this, AppScanFragment::class.java)
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.angcyo:QrCodeZxingZbar:1.0.2'
}
https://github.com/XieZhiFa/ZxingZbar
库中已经自带了混淆规则, 手动添加如下:
-keep class net.sourceforge.zbar.**{*;}
-keep class com.google.zxing.client.android.**{*;}
扫码安装
群内有各(pian)种(ni)各(jin)样(qun)
的大佬,等你来撩.