+ 2
Godot Android Game Permissions
Hello! I have made a game with godot and am ready to export it to android. But in order to save the highscores and the unlocked player-skins, I would need permission to the storage. Godot doesn't ask for this automatically, and that the user would have to go to the settings and enable permissions is a bit inconvenient. I have found this module: https://github.com/vanyasem/Godot-AndroidPermissions , I just don't understand what, in the example, "Globals" is. If anyone has experience and can help, I would be really glad to hear it! Thanks in advance!
1 ответ
+ 2
Try this:
Create a method:
private boolean perm(int a) {
if (Build.VERSION.SDK_INT >= 23) {
if (checkSelfPermission(android.Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
return true;
} else {
this.requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 0);
return false;
}
} else {
return true;
}
}
Then call it like this:
if (!perm(2)) {
//Permission not granted
} else {
//Permission granted
}