SDL
SDL copied to clipboard
Android: `ASensorManager_getInstance()` deprecated since API level 26
The SDL Sensor API in Android currently uses ASensorManager_getInstance() to initialize sensors. However, this function has been deprecated since API level 26 and replaced with ASensorManager_getInstanceForPackage() instead. More info here.
This deprecation generates the following warning when building:
C/C++: src/sensor/android/SDL_androidsensor.c:56:26: warning: 'ASensorManager_getInstance' is deprecated: first deprecated in Android 26 - Use ASensorManager_getInstanceForPackage instead [-Wdeprecated-declarations]
C/C++: 56 | SDL_sensor_manager = ASensorManager_getInstance();
C/C++: | ^
C/C++: /opt/android-sdk/ndk/27.2.12479018/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/android/sensor.h:751:17: note: 'ASensorManager_getInstance' has been explicitly marked deprecated here
C/C++: 751 | ASensorManager* ASensorManager_getInstance()
C/C++: | ^
C/C++: 1 warning generated.
This is the only warning we can see about SDL (using version 2.30.9, but the same code is used in SDL3) at the moment.
Perhaps a pre-processor condition could be used to use the older function if API level < 26 and the new one otherwise?