We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
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("打开失败,请授予相机权限") } }
<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"/>
### Logs "main" prio=5 tid=1 TimedWaiting | group="main" sCount=0 dsCount=0 flags=0 obj=0x7177b168 self=0xe1c05410 | sysTid=28527 nice=-10 cgrp=default sched=0/0 handle=0xea4e4470 | state=? schedstat=( 0 0 0 ) utm=0 stm=0 core=0 HZ=100 | stack=0xff0dc000-0xff0de000 stackSize=8192KB | held mutexes= at sun.misc.Unsafe.park(Native method) - waiting on an unknown object at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:230) at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedNanos(AbstractQueuedSynchronizer.java:1063) at java.util.concurrent.locks.AbstractQueuedSynchronizer.tryAcquireSharedNanos(AbstractQueuedSynchronizer.java:1358) at java.util.concurrent.CountDownLatch.await(CountDownLatch.java:278) at com.otaliastudios.cameraview.engine.CameraEngine.destroy(CameraEngine.java:313) at com.otaliastudios.cameraview.engine.CameraEngine.destroy(CameraEngine.java:325) at com.otaliastudios.cameraview.engine.CameraEngine.destroy(CameraEngine.java:289) at com.otaliastudios.cameraview.CameraView.destroy(CameraView.java:893)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
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: