You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@natario1 I also found this problem in the operation of the camera in the project, which can basically reach one-tenth of the probability in the scene where the camera is frequently turned on and off. Is there any way to avoid it?
Describe the bug
To Reproduce
private fun initCameraView() {
camera.setLifecycleOwner(this)
camera.addCameraListener(Listener())
}
override fun onRequestPermissionsResult(
requestCode: Int,
permissions: Array<String?>,
grantResults: IntArray
) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
val valid = grantResults.all { it == PackageManager.PERMISSION_GRANTED }
if (valid && !camera.isOpened) {
camera.open()
} else if (!valid) {
ToastUtils.showShort("打开失败,请授予相机权限")
}
}
XML layout
<com.otaliastudios.cameraview.CameraView
android:id="@+id/camera"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:gravity="center"
android:keepScreenOn="true"
app:cameraExperimental="true"
app:cameraEngine="camera2"
app:cameraPreview="texture"
app:cameraPlaySounds="true"
app:cameraGrid="off"
app:cameraFlash="torch"
app:cameraWhiteBalance="auto"
app:cameraHdr="off"
app:cameraPictureMetering="true"
app:cameraAudio="off"
app:cameraFacing="back"
app:cameraGestureTap="autoFocus"
app:cameraGestureLongTap="none"
app:cameraGesturePinch="zoom"
app:cameraGestureScrollHorizontal="none"
app:cameraGestureScrollVertical="none"
app:cameraMode="picture"
app:cameraPictureFormat="jpeg"
app:cameraAutoFocusMarker="@string/cameraview_default_autofocus_marker"/>
The text was updated successfully, but these errors were encountered: