Android 14 function adaptation

Translated from Google Developer Platform

Behavior Changes: All Apps

The Android 14 platform includes behavior changes that may affect apps. The following behavior changes apply to all apps running on Android 14, regardless of targetSdkVersion. You should test your application and then modify it as necessary to support these features appropriately.

Make sure to also check out the list of behavior changes that only affect apps targeting Android 14.

Core functions

By default, scheduled precision alerts are rejected

Precise alerts are used for user intent notifications, or for actions that need to happen at a precise time. Starting with Android 14, most newly installed apps targeting Android 13 and later no longer pre-grant the SCHEDULE_EXACT_ALARM permission. By default, this permission is denied.

Learn more about changes to scheduling precision alert permissions.

Context registered broadcasts will be queued when the app is cached

On Android 14, the system can queue context-registered broadcasts while the app is in the cached state. This is similar to the queuing behavior introduced by Android 12 (API level 31) for asynchronous binder transactions. Broadcasts declared by the manifest are not queued, and the application is removed from cached state for broadcast delivery.

The system sends any queued broadcasts when the app leaves the cached state (for example, returns to the foreground). Multiple instances of some broadcasts can be combined into one broadcast.

Apps can only kill their own background processes

Starting with Android 14, the API can only kill your own app's background processes when your app calls killBackgroundProcesses().

If another application's package name is passed in, this method has no effect on that application's background processes, and the following message will appear in Logcat:

Invalid package name: com.example.anthrapp

Your application should not use the killBackgroundProcesses() API, or attempt to affect the process lifecycle of other applications, even on older OS versions. Android is designed to keep cached apps in the background and close them automatically when the system needs memory. If your application kills other applications unnecessarily, it may reduce system performance and increase battery consumption, which requires restarting those applications later, which requires more resources than restoring existing cached applications .

NOTE: It is not possible for third-party apps to improve the memory, power consumption, or thermal performance of Android devices. You should ensure that your app complies with Google Play's policy on misleading claims.

Safety

Minimum installable target API level

Starting from Android 14, apps with targetSdkVersion lower than 23 cannot be installed. Requiring applications to meet these minimum target API level requirements increases security and privacy for users.

Malware often targets older API levels to bypass security and privacy protections introduced in newer Android versions. For example, some malware apps use targetSdkVersion 22 to avoid being affected by the runtime permission model introduced in 2015 with Android 6.0 Marshmallow (API level 23). This change in Android 14 makes it harder for malware to avoid security and privacy improvements. Attempts to install an application targeting a lower API level will cause the installation to fail with the following message in Logcat:

INSTALL_FAILED_DEPRECATED_SDK_VERSION: Application bundles must target at least SDK version 23, but 7 was found

On devices upgraded to Android 14, any app with a targetSdkVersion lower than 23 will continue to install.

If you need to test an application targeting an older API level, use the following ADB command:

adb install --bypass low target sdk block FILENAME.apk

Media owner package names may be edited

The media store supports queries on the OWNER_PACKAGE_NAME column, which indicates the application that stores a particular media file. Starting with Android 14, this value will be edited unless at least one of the following conditions is met:

Apps that store media files have a package name that is always visible to other apps.

Applications that query media storage request the QUERY_ALL_PACKAGES permission.

WARNING: Use of the QUERY_ALL_PACKAGES permission is subject to Google Play Policies.

Learn more about how Android filters packet visibility for privacy purposes.

user experience

Changes to how users experience irrevocable notifications

If your app displays irrevocable foreground notifications to the user, Android 14 has changed the behavior to allow users to dismiss such notifications.

This change applies to apps that prevent users from dismissing foreground notifications by setting Notification.FLAG_ONGONG_EVENT via Notification.Builder#setOngoing(true) or NotificationCompat.Builder#setIngoing(true). The behavior of FLAG_ONGOING_EVENT has been changed so that the user can actually dismiss such notifications.

Guess you like

Origin blog.csdn.net/ziyunLLL/article/details/129495523