Android 12 introduced new features and behaviors, from permissions to security, that affect directly the NAO® SDK. All the changes are described on Android 12’s documentation.
NAO® SDK Release 21.02 (v4.10.x) will still work as expected with applications targeting Android 11.
However, it is not compatible with applications targeting Android 12. You will need to integrate the Release 21.09 (NAO® SDK version 4.11.3).
“Approximate location” permission model.
On Android 12, users can navigate to system settings to set the preferred location accuracy for any app, regardless of that app’s target SDK version. This is true even when your app is installed on a device running Android 11 or lower, and then upgrades to Android 12. If the user downgrades your app’s location access from precise to approximate, either from the permission dialog or in system settings, the system restarts your app’s process. NAO® SDK requires ACCESS_FINE_LOCATION
permission to work.
Please refer to the Android documentation: https://developer.android.com/about/versions/12/approximate-location.
To request that the user upgrade your app’s location access from approximate to precise, do the following:
ACCESS_FINE_LOCATION
and ACCESS_COARSE_LOCATION
permissions together again. Because the user has already allowed the system to grant approximate location to your app, the system dialog is different this time.Background location permission ACCESS_BACKGROUND_LOCATION
has to be requested separately.
There are new bluetooth permissions. Please refer to the Android 12 documentation: https://developer.android.com/about/versions/12/features/bluetooth-permissions.
If your app targets Android 12 it must declare the new introduced BLUETOOTH_SCAN
permission, which lets your app scan for nearby devices without needing to request the location permission. This is a runtime permission, therefore, you must explicitly request user approval in your app.
Apps that target Android 12 can no longer start foreground services while running in the background, except for a few special cases. If an app attempts to start a foreground service while running in the background, an exception occurs (except for the few special cases). Consider using WorkManager to schedule and start work while your app runs in the background.
Application that target Android 12 and use exact alarms should only be used for user-facing features, such as one of the situations described in the acceptable use cases section. Otherwise application should obtain a special app access by requesting the SCHEDULE_EXACT_ALARM
permission in the manifest.
There are several situations to consider. Here under a table to summarize how the NAO® SDK would behave according to app life-cycle events and OS configurations.
If you need a reminder on how to integrate the NAO® SDK with previous versions of Android, feel free to read https://docs.nao-cloud.com/docs/misc/android-update/.