You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SDL_AndroidRequestPermission/SDL_RequestAndroidPermission fails when requesting unknown permissions, e.g. when you request the notification permission on a platform before Android 13 where this permission did not exist. Best practice according to the documentation is to use ContextCompat and ActivityCompat to request permissions, e.g. in
- if (activity.checkSelfPermission(permission) != PackageManager.PERMISSION_GRANTED) {- activity.requestPermissions(new String[]{permission}, requestCode);+ if (ContextCompat.checkSelfPermission(activity, permission) != PackageManager.PERMISSION_GRANTED) {+ ActivityCompat.requestPermissions(activity, new String[]{permission}, requestCode);
That would result in SDL_AndroidRequestPermission returning a result indicating that the permission was granted for unknown permission IDs. This applies to both SDL2 and 3.
As a workaround we added a check in our project to not request the notification permission on API lower than 33, but that doesn't properly check if notifications are allowed by the notification manager.
It seems like using AndroidX is best practice for new Android projects to simplify supporting different API levels, but I understand if you don't want to add more dependencies to the existing project. I looked a bit through the project files and it doesn't seem like there are many use cases for AndroidX yet.
SDL_AndroidRequestPermission
/SDL_RequestAndroidPermission
fails when requesting unknown permissions, e.g. when you request the notification permission on a platform before Android 13 where this permission did not exist. Best practice according to the documentation is to useContextCompat
andActivityCompat
to request permissions, e.g. inSDL/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
Lines 1780 to 1785 in fc608ff
apply the patch
That would result in
SDL_AndroidRequestPermission
returning a result indicating that the permission was granted for unknown permission IDs. This applies to both SDL2 and 3.See also:
This would however also require adding the imports
and Gradle dependency
The text was updated successfully, but these errors were encountered: