pull/32/head
GKF 6 years ago
parent 05a028bfaa
commit d9f57f5e27
  1. 12
      app/src/main/java/io/legado/app/ui/qrcode/QrCodeActivity.kt

@ -58,19 +58,19 @@ class QrCodeActivity : BaseActivity<AndroidViewModel>(), QRCodeView.Delegate {
override fun onStart() { override fun onStart() {
super.onStart() super.onStart()
startCamera()
}
private fun startCamera() {
PermissionsCompat.Builder(this) PermissionsCompat.Builder(this)
.addPermissions(*Permissions.Group.CAMERA) .addPermissions(*Permissions.Group.CAMERA)
.rationale(R.string.qr_per) .rationale(R.string.qr_per)
.onGranted { .onGranted {
zxingview.startCamera() // 打开后置摄像头开始预览,但是并未开始识别 startCamera()
zxingview.startSpotAndShowRect() // 显示扫描框,并开始识别
}.request() }.request()
} }
private fun startCamera() {
zxingview.startCamera() // 打开后置摄像头开始预览,但是并未开始识别
zxingview.startSpotAndShowRect() // 显示扫描框,并开始识别
}
override fun onStop() { override fun onStop() {
zxingview.stopCamera() // 关闭摄像头预览,并且隐藏扫描框 zxingview.stopCamera() // 关闭摄像头预览,并且隐藏扫描框
super.onStop() super.onStop()

Loading…
Cancel
Save