Android 13 Behavioral Changes

In this document, we will explain the various Android 13 (API Level 33) behavioral changes that are observed when apps run on Android 13 devices.

Runtime Permissions for Notifications

With the Android 13 release, Google has introduced a runtime permission for notifications. The Android OS handles the notification access based on the TargetSDK level of the installed app as follows:

  • For an existing app that is already installed on the device:
    • If the TargetSDK API Level of the app is 32 (or lower), the OS temporarily grants the app with permission to display notifications. The app displays notifications until the user explicitly selects an option in the dialog box. Users can modify the permission in the System Settings to stop the temporary approval for permission.
    • If the TargetSDK API Level of the app is 33, the OS temporarily grants the app with permission to display notifications. The app displays notifications until the user launches an activity in the app. The app must also have an existing notification channel, and the user must not have explicitly disabled the app's notifications.
  • For a new app that is installed on the device:
    • If the TargetSDK API Level of the app is 32 (or lower), the OS displays the runtime permission dialog box when the app is relaunched and triggers a notification (the app creates its first notification channel).
    • If the TargetSDK API Level of the app is 33, you must add the android.permission.POST_NOTIFICATIONS permission in the app's Manifest file. The app displays a runtime prompt that requests the user to grant permission as the permission has a high protection level (dangerous).

      NOTE: For apps that do not have this permission granted by the user, the OS silently drops notifications for the app.

If the Target SDK API level is set as 33, and the app uses the Push Notifications APIs , Local Notifications APIs, or APIs related to Foreground Services (such as kony.application.startForegroundService, kony.application.stopForegroundService, kony.application.updateForegroundNotification) in Quantum Visualizer, ensure that you enable support for runtime permissions for notifications.
To do so, navigate to Project Settings > Native > Android Mobile / Tablet, and add the POST_NOTIFICATION permission in the Permissions tab.

The runtime permission notification dialog box contains the Allow and Don't Allow options.
If the user selects Allow, the app displays notifications through any channel, and displays notifications related to foreground services.
If the user swipes the notification away, the app can only display notifications if the OS grants a temporary access to the app to send notifications.
If the user selects Don't Allow, the app cannot display notifications through any channel except for a few specific roles. To enable notifications again, the user must manually enable notifications through the System Settings. However, if the app still does not display notifications, the user must uninstall the app and reinstall it after the TargetSDK version of the app has been updated. After the app is installed, the runtime permission request appears with the Allow and Don't Allow options. The user must then enable notifications to receive notifications.

Granular Media Permissions

With the Android 13 release, Google has introduced a new set of permissions that provide a granular scope to access the shared media files of a device. Apps will now use the following permissions instead of the READ_EXTERNAL_STORAGE permission:

  • READ_MEDIA_IMAGES permission for images and photos
  • READ_MEDIA_VIDEO permission for videos
  • READ_MEDIA_AUDIO permission for audio files

The Android OS handles the media access based on the TargetSDK level of the installed app as follows:

  • If the TargetSDK API Level of the app is 32 (or lower), the app would request the READ_EXTERNAL_STORAGE permission to access shared media files available in the local storage of the device.
  • If the TargetSDK API Level of the app is 33, you must add the android.permission.READ_MEDIA_AUDIO, android.permission.READ_MEDIA_IMAGES, and android.permission.READ_MEDIA_VIDEO permissions in the app's Manifest file. The app displays a system prompt that requests the user to grant permission to access the shared media files.

    NOTE: When a user grants one of these permissions to an app, the app will only have read access to the respective media file types.

If the Target SDK API level is set as 33, and the app uses the kony.phone.openMediaGallery API, the writeToMediaGallery or findImageInGallery Methods of the Image API in Quantum Visualizer, ensure that you enable support for granular media permissions.
To do so, navigate to Project Settings > Native > Android Mobile / Tablet, and add the following entries in the Permissions tab based on the type of media files you want to access:

  • Enable the READ_MEDIA_IMAGES permission to access image files.
  • Enable the READ_MEDIA_AUDIO permission to access audio file.
  • Enable the READ_MEDIA_VIDEO permission to access video files.

The system permission dialog box contains the Allow and Don't Allow options.
If the user selects Allow, the app can access the requested media files (audio, video, or images).
If the user selects Don't Allow, or swipes the notification away, the app cannot access the requested media files (audio, video, or images). To enable access to the media files again, the user must manually enable the permission through the System Settings.

Foreground Service Task Manager

In Android 13 devices, users can stop foreground services from the Foreground Services (FGS) Task Manager in the notification drawer. The Foreground Services Task Manager displays a list of apps that are currently running a foreground service (called active apps) with a Stop button next to each app. When a user taps the Stop button next to an app, the entire app stops (including the running foreground service).

Dismiss Foreground Service Notifications

In Android 13 devices, users can swipe foreground service (FGS) notifications away, by default. If the foreground services of an app have been running for more than 20 hours in a 24-hour window, the OS displays an interactive notification to the user through the Foreground Services Task Manager. However, if the foreground service is of the FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK or FOREGROUND_SERVICE_TYPE_LOCATION types, the OS does not display the foreground service notification.

Migrate Existing Apps to Android 13

Follow these steps to migrate an existing app to use the Android Target SDK API level 33:

  1. Download the Android SDK Build Tools version 33.0.2, and place it in the <Android SDK path>/build-tools location.
  2. Set the Target SDK Level of the app to Level 33
    To do so, navigate to Project Settings > Native > Android Mobile / Tablet > SDK Versions section, and select 13.0 (33) from the Target SDK drop-down.
  3. Add Notification Permissions

    If your app uses the Push Notifications APIs , Local Notifications APIs, or APIs related to Foreground Services (such as kony.application.startForegroundService, kony.application.stopForegroundService, kony.application.updateForegroundNotification) in Quantum Visualizer, ensure that you enable support for runtime permissions for notifications.
    To do so, navigate to Project Settings > Native > Android Mobile / Tablet, and add the POST_NOTIFICATION permission in the Permissions tab.

  4. Add Media Permissions

    In the Android 13 release, the READ_EXTERNAL_STORAGE is replaced to support granular media permissions. You must declare the type of media that the app must be able to access .
    To do so, navigate to Project Settings > Native > Android Mobile / Tablet, and add the following entries in the Permissions tab based on the type of media files you want to access:

    • Enable the READ_MEDIA_IMAGES permission to access image files.
    • Enable the READ_MEDIA_AUDIO permission to access audio file.
    • Enable the READ_MEDIA_VIDEO permission to access video files.

    To maintain backward compatibility, you must also add the READ_EXTERNAL_STORAGE permission with the maxSdkVersion set to SDK level 32.
    To do so, navigate to Project Settings > Native > Android Mobile / Tablet, and add the following entries in the build.gradle entries to suffix section of the Gradle Entries tab:
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="32" />

  5. Declare Advertising ID in the Google Play Console

    While publishing an Android 13 app to the Google Play Store, you must declare the advertising ID in the Google Play Console by adding the com.google.android.gms.permission.AD_ID permission in the AndroidManifest file of the app.

    To do so, navigate to Project Settings > Native > Android Mobile / Tablet, and add the following entry in the Child Tag entries Under Manifest tag section of the Tags tab:
    <uses-permission android:name="com.google.android.gms.permission.AD_ID"/>