I have a method in order to show request permissions if needed
static boolean requestPermission(int id, String... permissions) {
System.out.println("REQUEST PERMISSION METHOD");
boolean granted = true;
ArrayList<String> list = new ArrayList<>();
for (String s : permissions) {
int check = ContextCompat.checkSelfPermission(this, s);
boolean hasPermission = (check == PackageManager.PERMISSION_GRANTED);
granted &= hasPermission;
if (!hasPermission) {
list.add(s);
}
}
if (granted) {
return true;
} else {
ActivityCompat.requestPermissions(this, permissionsNeeded.toArray(new String[permissionsNeeded.size()]), id);
return false;
}
}
This method worked till Android 13 that I'm testing with latest official Android emulator in Android Studio, now if onResume()
I call e.g.
requestPermission(id,
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE));
I have a loop of inconclusive requests: I don't get any crash but in log cat I have continue "REQUEST PERMISSION METHOD"
prints, the string print placed at the start of the method as if the method is invoked continuously somehow.
Why this? How should I fix this problem?