Android 判断设备是否有可用的摄像头

fun checkCameraEnable(): Boolean {
            var canUse = false
            var mCamera: Camera? = null

            try {
                mCamera = Camera.open(0)
                val mParameters = mCamera.parameters
                mCamera.parameters = mParameters
            } catch (e: java.lang.Exception) {
                canUse = false
            }

            if (mCamera != null) {
                mCamera.release()
                canUse = true
            }

            return canUse

        }

0 0 vote
Article Rating
Subscribe
提醒
guest
0 评论
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x