Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POSIBLES MEJORAS DE PERMISOS #6

Open
manelcc opened this issue Dec 15, 2022 · 1 comment
Open

POSIBLES MEJORAS DE PERMISOS #6

manelcc opened this issue Dec 15, 2022 · 1 comment

Comments

@manelcc
Copy link

manelcc commented Dec 15, 2022

checkLocationPermission();
}
private void checkLocationPermission() {
ActivityResultLauncher<String[]> locationPermissionRequest =
registerForActivityResult(new ActivityResultContracts.RequestMultiplePermissions(), result -> {
Boolean fineLocationGranted = result.getOrDefault(permissions[1], false);
Boolean coarseLocationGranted = result.getOrDefault(permissions[0], false);
if (fineLocationGranted != null && !fineLocationGranted ||
coarseLocationGranted != null && !coarseLocationGranted) {
showPermissionInfo();
} else {
userWelcome();
}
});
locationPermissionRequest.launch(permissions);
}

@Albrodiaz me parece bien, ya que usas la ActivityResult para los permisos. Puedes poner el callback como una variable en la declaración de variables (ponerla como private), y el método sobrará porque donde invocas al método solo necesitas lanzar la activityResult.

@Albrodiaz
Copy link
Owner

Albrodiaz commented Dec 15, 2022

No se si lo he entendido bien. Elimino el método y la variable locationPermissionRequest la inicializo debajo del array de permisos. Después, elimino la llamada al método y lanzo en su lugar el launch del locationPermissionRequest . ¿Sería así?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants