La plataforma de Android 14 incluye cambios de comportamiento que podrían afectar a tu app.
Los siguientes cambios se aplican a todas las apps cuando se ejecutan en Android 14,
independientemente de
targetSdkVersion. Debes probar tu app y, luego, modificarla según corresponda para admitir estos cambios.
Asegúrate también de consultar la lista de cambios de comportamiento que solo afectan a las apps orientadas a Android 14.
Funcionalidad principal
El permiso para programar alarmas exactas se rechaza de forma predeterminada
精确的闹钟适用于用户指定的通知,或是在确切时间需要执行的操作。从 Android 14 开始,系统不再向以 Android 13 及更高版本为目标平台的大多数新安装应用预先授予 SCHEDULE_EXACT_ALARM 权限,该权限默认处于拒绝状态。
详细了解安排精确闹钟的权限变化。
Las transmisiones registradas en el contexto se ponen en cola mientras las apps se almacenan en caché
On Android 14, the system can place context-registered broadcasts in a queue while the app is in the cached state. This is similar to the queuing behavior that Android 12 (API level 31) introduced for async binder transactions. Manifest-declared broadcasts aren't queued, and apps are removed from the cached state for broadcast delivery.
When the app leaves the cached state, such as returning to the foreground, the system delivers any queued broadcasts. Multiple instances of certain broadcasts might be merged into one broadcast. Depending on other factors, such as system health, apps might be removed from the cached state, and any previously queued broadcasts are delivered.
Las apps solo pueden finalizar sus propios procesos en segundo plano
A partir de Android 14, cuando tu app llame a killBackgroundProcesses(), la API solo puede finalizar los procesos en segundo plano de tu propia app.
Si pasas el nombre del paquete de otra app, este método no tiene efecto en los procesos en segundo plano de esa app, y aparece el siguiente mensaje en Logcat:
Invalid packageName: com.example.anotherapp
Tu app no debe usar la API de killBackgroundProcesses() ni intentar influir, de otra manera, en el ciclo de vida del proceso de otras apps, incluso en versiones anteriores del SO.
Android se diseñó para mantener las apps almacenadas en caché en segundo plano y eliminarlas automáticamente cuando el sistema necesite memoria. Si tu app finaliza, de forma innecesaria, otras apps, puede reducir el rendimiento del sistema y aumentar el consumo de batería, ya que se requieren reinicios completos de esas apps más adelante, lo que exige muchos más recursos que reanudar una app existente almacenada en caché.
La MTU se establece en 517 para el primer cliente GATT que solicita una MTU.
从 Android 14 开始,Android 蓝牙堆栈会更严格地遵循 蓝牙核心规范 5.2 版,并在第一个 GATT 客户端使用 BluetoothGatt#requestMtu(int) API 请求 MTU 时将 BLE ATT MTU 请求设为 517 字节,并忽略该 ACL 连接上的所有后续 MTU 请求。
如需解决此更改并使您的应用更为稳健,请考虑以下选项:
- 您的外围设备应使用外围设备可以容纳的合理值来响应 Android 设备的 MTU 请求。最终协商的值将是 Android 请求的值和远程提供的值(例如
min(517, remoteMtu))的较小值- 实现此修复程序可能需要更新外围设备的固件
- 或者,您也可以根据外围设备的已知支持值与收到的 MTU 更改值之间的最小值来限制 GATT 特征写入
- 提醒您,应将标头的支持大小减小 5 个字节
- 例如:
arrayMaxLength = min(SUPPORTED_MTU, GATT_MAX_ATTR_LEN(517)) - 5
Nuevo motivo por el que una app puede colocarse en el bucket de espera restringido
Android 14 introduces a new reason an app can be placed into the restricted standby bucket.
The app's jobs trigger ANR errors multiple times due to onStartJob,
onStopJob, or onBind method timeouts.
(See JobScheduler reinforces callback and network behavior for changes
to onStartJob and onStopJob.)
To track whether or not the app has entered the restricted standby bucket,
we recommend logging with the API UsageStatsManager.getAppStandbyBucket()
on job execution or UsageStatsManager.queryEventsForSelf() on app startup.
mlock limitado a 64 KB
在 Android 14(API 级别 34)及更高版本中,平台将可使用 mlock() 锁定的最大内存量减少到每个进程 64 KB。在之前的版本中,每个进程的上限为 64 MB。此限制有助于更好地管理应用和系统的内存。为了在各种设备上提供更一致的体验,Android 14 针对兼容设备上的新 mlock() 限制添加了一项新的 CTS 测试。
El sistema aplica el uso de recursos de las apps almacenadas en caché
By design, an app's process is in a cached state when it's moved to the
background and no other app process components are running. Such an app process
is subject to being killed due to system memory pressure. Any work that
Activity instances perform after the onStop() method has been called and
returned, while in this state, is unreliable and strongly discouraged.
Android 14 introduces consistency and enforcement to this design. Shortly after an app process enters a cached state, background work is disallowed, until a process component re-enters an active state of the lifecycle.
Apps that use typical framework-supported lifecycle APIs – such as
services, JobScheduler, and Jetpack WorkManager – shouldn't be
impacted by these changes.
Experiencia del usuario
Cambios en la experiencia de los usuarios con notificaciones que no se pueden descartar
If your app shows non-dismissable foreground notifications to users, 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_ONGOING_EVENT through
Notification.Builder#setOngoing(true) or
NotificationCompat.Builder#setOngoing(true). The behavior of
FLAG_ONGOING_EVENT has changed to make such notifications actually
dismissable by the user.
These kinds of notifications are still non-dismissable in the following conditions:
- When the phone is locked
- If the user selects a Clear all notification action (which helps with accidental dismissals)
Also, this new behavior doesn't apply to notifications in the following use cases:
CallStylenotifications- Device policy controller (DPC) and supporting packages for enterprise
- Media notifications
- The default Search Selector package
La información de seguridad de los datos es más visible
To enhance user privacy, Android 14 increases the number of places where the system shows the information you have declared in the Play Console form. Currently, users can view this information in the Data safety section on your app's listing in Google Play.
We encourage you to review your app's location data sharing policies and take a moment to make any applicable updates to your app's Google Play Data safety section.
Learn more in the guide about how data safety information is more visible on Android 14.
Accesibilidad
Escalamiento de fuente no lineal al 200%
从 Android 14 开始,系统支持将字体放大至最高 200%,为用户提供更多无障碍选项。
如果您已使用可缩放像素 (sp) 单位来定义文本大小,这项更改可能不会对您的应用产生太大影响。不过,您应在启用最大字号 (200%) 的情况下执行界面测试,确保应用能够在不影响易用性的情况下适应较大的字号。
Seguridad
Nivel mínimo de API objetivo instalable
A partir de Android 14, no se pueden instalar apps con un targetSdkVersion inferior a 23. Exigir a las apps que cumplan con estos requisitos mínimos del nivel de API objetivo mejora la seguridad y la privacidad de los usuarios.
Con frecuencia, el software malicioso se orienta a niveles de APIs más antiguos para evitar las protecciones de seguridad y privacidad que se introdujeron en las versiones más recientes de Android. Por ejemplo, algunas apps de software malicioso usan targetSdkVersion de 22 para evitar que estén sujetas al modelo de permisos de tiempo de ejecución que, en 2015, introdujo Android 6.0 Marshmallow (nivel de API 23). Este cambio en Android 14 dificulta que el software malicioso evite las mejoras de seguridad y privacidad.
Si intentas instalar una app que se oriente a un nivel de API inferior, se producirá un error de instalación y se mostrará el siguiente mensaje en Logcat:
INSTALL_FAILED_DEPRECATED_SDK_VERSION: App package must target at least SDK version 23, but found 7
En los dispositivos que se actualizan a Android 14, las apps que tengan un targetSdkVersion inferior a 23 permanecerán instaladas.
Si necesitas probar una app que se oriente a un nivel de API anterior, usa el siguiente comando de adb:
adb install --bypass-low-target-sdk-block FILENAME.apk
Los nombres de los paquetes de los propietarios del contenido multimedia podrían estar ocultos
媒体库支持查询 OWNER_PACKAGE_NAME 列,该列表示存储特定媒体文件的应用。从 Android 14 开始,除非满足以下条件之一,否则系统会隐去此值:
- 存储媒体文件的应用有一个软件包名称始终对其他应用可见。
查询媒体库的应用会请求
QUERY_ALL_PACKAGES权限。
详细了解 Android 如何出于隐私保护目的而过滤软件包可见性。