My current Android application employs jetpack compose and requires the MANAGE_EXTERNAL_STORAGE permission to be granted.
My application has the following code to start activity for result and allow the user to grant this permission:-
val launcher = rememberLauncherForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
// What should I expect to code here?
}
I request the permission on a button click as shown here:-
val uri = Uri.parse("package:$myPackageName")
Button(
onClick = {
launcher.launch(Intent(ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION, uri))
}
) {
}
My issue is that the user has to navigate back to my application once they have enabled full file access, therefore the result I receive in the callback is always
ActivityResult{resultCode=RESULT_CANCELED, data=null}
I then have to check whether or not the user has granted permission using
Environment.isExternalStorageManager()
is there no other alternative?
is there any method the user can employ that returns the result from the settings screen where they enable the permission itself?