CameraX閃光燈,app內打開跳轉系統相冊

閃光燈

    val imageCaptureConfig = ImageCaptureConfig.Builder().apply {//在config裏面設置
            setLensFacing(lensFacing)
            setCaptureMode(ImageCapture.CaptureMode.MIN_LATENCY)
            setFlashMode(flashMode)
            setTargetRotation(texture_view.display.rotation)
        }.build()

FlashMode.AUTO/FlashMode.OFF/FlashMode.ON
有這三種模式。

打開系統相冊

在點擊事件中

val intent = Intent()
            intent.type = "image/*"
            intent.action = Intent.ACTION_GET_CONTENT
            startActivityForResult(intent, REQUEST_CODE_SELECT_PHOTO)

並重寫在點擊事件所在的Activity的onActivityResult

      if (resultCode == Activity.RESULT_OK) {
            if (requestCode == REQUEST_CODE_SELECT_PHOTO) {
            //todo
            }
        }
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章