Android 12 Updates

Android 12 (API 31) comes with new features and API changes.
All of the behavior changes are well-documented on the Android Developer platform - Android 12 Behavior changes.

There are changes for all apps, no matter if targeting API 31 or just running on Android 12. Some of those include Splash Screen API changes, Web intent resolution, permissions and other. The full list can be found here.


Leanplum Android SDK 5.8.0 supports Android 12

If you plan to increase the target API of your app to 31, you must upgrade Leanplum SDK to 5.8.0 or higher.
If you use Advertising ID, see section Advertising ID and upgrade to Leanplum SDK 5.8.2.

It is important to note that the below changes affect only apps that target API 31.

Notification trampolines

The most prominent one is about Notification trampoline restrictions. The system prevents components that start other activities inside services or broadcast receivers when notification is opened. If this requirement is not met, the system will prevent the activity from starting.
This can result in Open Action not working.

SDK changes

In Leanplum Android SDK 5.8.0, we have made several changes and the most significant one is the handling of push notifications (#470).

In prior versions, PendingIntent instance is used inside the notification to open our broadcast receiver LeanplumPushReceiver, and then we do the rest - starting the activity, tracking the Push Opened event, and running the Open Action.

New changes restrict usage of notification trampolines, meaning that notification must start the activity directly on the notification tap.
Tracking of Push Opened event and running the Open Action happens in the ActivityLifecycleCallbacks instance registered by LeanplumActivityHelper.enableLifecycleCallbacks.
The push message is attached as an extra to the notification intent and processed when the notification is tapped.

Important Details

  • If you expect a notification to reopen an existing activity, you must override Activity onNewIntent and set the new intent to the activity object to allow Leanplum to parse the message payload:
protected void onNewIntent(Intent intent) {
  • If you configure push notification with Open URL action to open a third-party application, the SDK would not be able to track the Push Opened event as it wouldn’t receive any feedback when the notification is clicked.
  • If you use com.leanplum:leanplum-mipush for Mi Push messaging and your app targets SDK 31, ensure to test on a Xiaomi device running Android 12.

Advertising ID

Apps with target API level set to 31 (Android 12) or later, must declare the normal permission in the AndroidManifest.xml in order to use this API.
For apps with target API level set to 30 (Android 11) or older, this permission is not needed.
More details in Google's documentation.

Android 12 Safety section

Android 12 introduces Safety section that will be displayed on the app store page, which is similar to the privacy section on the iOS App Store.
The safety section will include details on what data the app collects.

Users will see the new summary on the Play Store listing page. It will share the developer’s explanation of what data an app collects or shares and highlight safety details.

The feature is scheduled to be launched by April 2022. Google is yet to deliver more information on the section. Read more on how to get prepared here.
You can also check our article on Apple App Privacy.

Custom notifications

In order to streamline User Experience when apps use entirely Custom Notification layouts, Android 12 will prevent such notifications to use the full notification area.
Android 12 introduces a standard template for the notifications, which ensures the same decoration for all notifications. It has a fixed header with the app name and a consistent expand/collapse appearance.
Detailed documentation and illustration are available in the official docs.

Play as you download

This allows users to start gaming quickly - it downloads only a small chunk of the game, while other remaining assets are downloaded in the background.
More information on the feature and how to get whitelisted: Android Game Guides.

Location changes

Users can now request that the app have access to only approximate location information.

WebView changes

Android’s WebView component changes the handling of third-party cookies to provide more security and privacy and offer users more transparency and control. If you app uses WebViews, check the updates guide here.

Pending intents mutability

To improve the security of your app, you must specify the mutability of each PendingIntent object that your app creates.
Leanplum Android SDK 5.8.0 complies with this.

Safer Component Exporting

If your app contains activities, services, or broadcast receivers that use intent filters, you must explicitly declare the android:exported attribute.