'How to limit ActivityResultContract.GetContent to media (image or video)
Is there a way to make ActivityResultContract.GetContent filter only media files?
private val selectMediaResultLauncher = registerForActivityResult(ActivityResultContracts.GetContent()) { uri: Uri? ->
// Do something with the uri
}
Tried to use:
selectMediaResultLauncher.launch("image/* video/*")
But no luck.
Thanks for assiting.
Solution 1:[1]
You can use OpenDocument()
private val selectMediaResultLauncher = registerForActivityResult(ActivityResultContracts.OpenDocument()) { uri ->
// Do something with the uri
}
and:
selectMediaResultLauncher.launch(arrayOf("image/*", "video/*"))
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | ????? ??????? |