I want to access all folders/files on external storage to display them on screen (like a file manager app) follow this document
It worked fine on Android 13 but on 14. On Android 14, the permission launcher always returns false. No error log or exception was thrown. Does anyone know the reason why? It's strange.
val permissionLauncher =
rememberLauncherForActivityResult(contract = ActivityResultContracts.RequestPermission(),
onResult = {
when {
it -> onPermissionGrant()
context.findActivity()
?.shouldShowRequestPermissionRationale(permissionNeed) == true -> {
}
else -> onPermissionDenied()
}
})
LaunchedEffect(key1 = Unit, block = {
permissionLauncher.launch(Manifest.permission.MANAGE_EXTERNAL_STORAGE)
})
Hmm I have realized my mistake in my case. There is no need to request the Manifest.permission.MANAGE_EXTERNAL_STORAGE permission at runtime. Just declare it in manifest then start an intent with this action ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION to drive users to the permission settings board and they will turn on directly if they want. That is the way!