我在"Intent(Inent.ACTION_VIEW)"(Android Kotlin)上遇到了麻烦,我已经搜索了整个互联网,但没有找到更新的解决方案.
看起来有点简单,在我的代码中,我有这样一行代码:
private fun openFilePicker() {
filePickerLauncher.launch("*/*")
}
private val filePickerLauncher = registerForActivityResult(ActivityResultContracts.GetContent()) { uri ->
if (uri != null) {
val filePath = uri.path
if (filePath != null) {
pdfPath = filePath
}
}
}
因此,在 Select 任何文件后,我的变量"pdfPath"有一个字符串,指向我刚刚 Select 的文件的路径,如:
pdfPath = /document/primary:ExampleFolder/Example.pdf
有没有办法打开这个有路径的文件?
OBS:文件位于手机内部.这可能是任何人在电话上,我只需要一种方法来打开一个特定的文件基于"pdfPath"的值