有没有办法让ActivityResultContract.GetContent只过滤媒体文件?
private val selectMediaResultLauncher = registerForActivityResult(ActivityResultContracts.GetContent()) { uri: Uri? ->
// Do something with the uri
}
尝试使用:
selectMediaResultLauncher.launch("image/* video/*")
但运气不好。
谢谢你的协助。
您可以使用OpenDocument((
private val selectMediaResultLauncher = registerForActivityResult(ActivityResultContracts.OpenDocument()) { uri ->
// Do something with the uri
}
和:
selectMediaResultLauncher.launch(arrayOf("image/*", "video/*"))