0

我将三个意图一起传递以显示相机、视频、画廊使用Intent.ACTION_CHOOSER但无法识别用户选择的选项:相机、视频或画廊。有什么方法可以识别操作registerForActivityResult

下面是我向用户显示这三个选项的代码:

val galleryIntent = Intent(Intent.ACTION_GET_CONTENT, null)
galleryIntent.type = "*/*"
val cameraIntent = Intent(MediaStore.ACTION_IMAGE_CAPTURE)
val videoIntent = Intent(MediaStore.ACTION_VIDEO_CAPTURE)
val chooser = Intent(Intent.ACTION_CHOOSER)
chooser.putExtra(Intent.EXTRA_INTENT, galleryIntent)
chooser.putExtra(Intent.EXTRA_TITLE, "CHOOSE AN ACTION")
    
val intentArray = arrayOf(cameraIntent, videoIntent)
chooser.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray)
resultLauncherCameraGallery.launch(chooser)
4

0 回答 0