
Choosing Video File in Android Application Using Android
txtVideoData = view.findViewById(R.id.txtVideoData)
var resultLauncher = registerForActivityResult(
ActivityResultContracts.StartActivityForResult()) { result ->
if (result.resultCode == Activity.RESULT_OK) {
// parse result and perform action
txtVideoData.text = "Video Path: ${result.data?.data?.path}"
}
}
btnOpenVideo = view.findViewById(R.id.btnOpenVideo)
btnOpenVideo.setOnClickListener {
// Start file chooser dialogue
val intent = Intent(Intent.ACTION_GET_CONTENT)
intent.type = "video/*"
resultLauncher.launch(intent)
}
Programming Language: Kotlin