m4gr3d / Godot-Android-Samples

Collection of Godot Android plugins
MIT License
43 stars 6 forks source link

Why is runtime permissions immediately displayed to the user as soon as my plugin loads #14

Closed kyadalu1 closed 10 months ago

kyadalu1 commented 11 months ago

I am trying to ask the user for runtime location permission, I am asking the permission on button click. Here is my Godot code and here is my android library

As you can see in my Godot code i call getLocation() method of my android library on button press but i don't understand why it shows it immediately as soon as my plugin is loaded. If i don't allow the permission and click in the button then as expected my location permission is again asked but i cannot understand why it is asked immediately as soon as the plugin loads

Even in my android library code if you check GodotAndroidPlugin class, requestPermissions() is called in getLocation() & getLocation() is only called on button press

I don't face such issue when i try to use it in my native android app.

m4gr3d commented 11 months ago

@kyadalu1 This is expected behavior due to the logic in https://github.com/godotengine/godot/blob/fbaab3cf537a892295aabdfd02c8052e370e6669/platform/android/java/lib/src/org/godotengine/godot/GodotActivity.kt#L70 which automatically requests runtime permissions when the Godot app starts.

kyadalu1 commented 11 months ago
  1. This seems like a bad practice to ask for all runtime permissions as soon as the game loads. A user will feel frustrated to see app asking dangerous permissions at the start without knowing what they are used for.
  2. When i go through this, i only see you asking Audio permission, in my case i was asking for location permission. Are all runtime permissions asked at app startup time, of course depending on what i have declared in the AndroidManifest.xml
m4gr3d commented 10 months ago
  1. This seems like a bad practice to ask for all runtime permissions as soon as the game loads. A user will feel frustrated to see app asking dangerous permissions at the start without knowing what they are used for.

@kyadalu1 That behavior is being reverted in https://github.com/godotengine/godot/pull/87080.

I expect the change to land in Godot 4.2.2 and Godot 4.3.

  1. When i go through this, i only see you asking Audio permission, in my case i was asking for location permission. Are all runtime permissions asked at app startup time, of course depending on what i have declared in the AndroidManifest.xml

It's the opposite, the Audio permission is being excluded from the request; the second argument is an exclude list.

m4gr3d commented 10 months ago

Closing since the PR has been merged.

myselfuser1 commented 10 months ago

@m4gr3d Thank you so much for your effort. Really appreciate it.