La piattaforma Android 14 include modifiche al comportamento che potrebbero interessare la tua app.
Le seguenti modifiche al comportamento si applicano a tutte le app quando vengono eseguite su Android 14,
indipendentemente da
targetSdkVersion. Devi testare la tua app e poi modificarla in base alle necessità per supportare correttamente questi comportamenti, ove applicabile.
Assicurati di esaminare anche l'elenco delle modifiche al comportamento che interessano solo le app che hanno come target Android 14.
Funzionalità di base
Per impostazione predefinita, la pianificazione delle sveglie esatte viene negata
精确的闹钟适用于用户指定的通知,或是在确切时间需要执行的操作。从 Android 14 开始,系统不再向以 Android 13 及更高版本为目标平台的大多数新安装应用预先授予 SCHEDULE_EXACT_ALARM 权限,该权限默认处于拒绝状态。
详细了解安排精确闹钟的权限变化。
Le trasmissioni registrate nel contesto vengono messe in coda mentre le app sono nella cache
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.
Le app possono terminare solo i propri processi in background
Starting in Android 14, when your app calls killBackgroundProcesses(),
the API can kill only the background processes of your own app.
If you pass in the package name of another app, this method has no effect on that app's background processes, and the following message appears in Logcat:
Invalid packageName: com.example.anotherapp
Your app shouldn't use the killBackgroundProcesses() API or otherwise attempt
to influence the process lifecycle of other apps, even on older OS versions.
Android is designed to keep cached apps in the background and kill them
automatically when the system needs memory. If your app kills other apps
unnecessarily, it can reduce system performance and increase battery consumption
by requiring full restarts of those apps later, which takes significantly more
resources than resuming an existing cached app.
L'MTU è impostato su 517 per il primo client GATT che richiede un MTU
A partire da Android 14, lo stack Bluetooth di Android rispetta più rigorosamente la versione 5.2 della Bluetooth Core Specification e richiede un MTU BLE ATT di 517 byte quando il primo client GATT richiede un MTU utilizzando l'API BluetoothGatt#requestMtu(int) e ignora tutte le richieste MTU successive su quella connessione ACL.
Per gestire questa modifica e rendere la tua app più solida, valuta le seguenti opzioni:
- La periferica deve rispondere alla richiesta MTU del dispositivo Android con un valore ragionevole che possa essere supportato dalla periferica. Il valore finale negoziato sarà un valore minimo del valore richiesto da Android e del valore fornito dal dispositivo remoto (ad esempio
min(517, remoteMtu)).- L'implementazione di questa correzione potrebbe richiedere un aggiornamento del firmware della periferica
- In alternativa, limita le scritture delle caratteristiche GATT in base al valore minimo tra il valore supportato noto della periferica e la variazione dell'MTU ricevuta.
- Ti ricordiamo che devi ridurre di 5 byte le dimensioni supportate per le intestazioni
- Ad esempio:
arrayMaxLength = min(SUPPORTED_MTU, GATT_MAX_ATTR_LEN(517)) - 5
Nuovo motivo per cui un'app può essere inserita nel bucket di standby con limitazioni
Android 14 引入了一种可将应用放入受限待机模式存储分区的新原因。由于 onStartJob、onStopJob 或 onBind 方法超时,应用的作业多次触发 ANR 错误。(如需了解对 onStartJob 和 onStopJob 的更改,请参阅 JobScheduler 强化了回调和网络行为。)
如需跟踪应用是否已进入受限待机分桶,我们建议您在作业执行时使用 API UsageStatsManager.getAppStandbyBucket() 进行日志记录,或在应用启动时使用 UsageStatsManager.queryEventsForSelf() 进行日志记录。
mlock limitato a 64 KB
在 Android 14(API 级别 34)及更高版本中,平台将可使用 mlock() 锁定的最大内存量减少到每个进程 64 KB。在之前的版本中,每个进程的上限为 64 MB。此限制有助于更好地管理应用和系统的内存。为了在各种设备上提供更一致的体验,Android 14 针对兼容设备上的新 mlock() 限制添加了一项新的 CTS 测试。
Il sistema applica l'utilizzo delle risorse delle app nella cache
从设计上讲,当应用的进程移至后台且没有任何其他应用进程组件在运行时,应用进程将处于缓存状态。此类应用进程可能会因系统内存压力而终止。在此状态下,Activity 实例在调用并返回 onStop() 方法后执行的任何工作均不可靠,强烈建议不要这样做。
Android 14 对此设计引入了一致性和强制执行要求。在应用进程进入缓存状态后不久,系统会禁止后台工作,直到进程组件重新进入生命周期的活跃状态。
使用框架支持的典型生命周期 API(例如服务、JobScheduler 和 Jetpack WorkManager)的应用应该不受这些变化的影响。
Esperienza utente
Modifiche al modo in cui gli utenti interagiscono con le notifiche non ignorabili
如果您的应用向用户显示不可关闭的前台通知,请注意:Android 14 已更改此行为,允许用户关闭此类通知。
这项变更适用于阻止用户关闭前台的应用
将 Notification.FLAG_ONGOING_EVENT 设置为
Notification.Builder#setOngoing(true) 或
NotificationCompat.Builder#setOngoing(true)。FLAG_ONGOING_EVENT 的行为已发生变化,使用户实际上能够关闭此类通知。
在以下情况下,此类通知仍不可关闭:
- 当手机处于锁定状态时
- 如果用户选择全部清除通知操作(有助于防止意外关闭)
此外,这一新行为不适用于以下用例中的通知:
CallStyle条通知- 企业设备政策控制器 (DPC) 和支持软件包
- 媒体通知
- 默认的搜索选择器软件包
Le informazioni sulla sicurezza dei dati sono più visibili
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.
Accessibilità
Ridimensionamento non lineare dei caratteri fino al 200%
A partire da Android 14, il sistema supporta il dimensionamento dei caratteri fino al 200%, offrendo agli utenti opzioni di accessibilità aggiuntive.
Se utilizzi già unità di pixel scalabili (sp) per definire le dimensioni del testo, questa modifica probabilmente non avrà un impatto elevato sulla tua app. Tuttavia, devi eseguire test dell'interfaccia utente con le dimensioni del carattere massime abilitate (200%) per assicurarti che la tua app possa supportare dimensioni del carattere più grandi senza influire sull'usabilità.
Sicurezza
Livello API target installabile minimo
A partire da Android 14, le app con un
targetSdkVersion minore di 23
non può essere installato. Richiedere alle app di soddisfare questi livelli API target minimi
di sicurezza migliorano la sicurezza e la privacy degli utenti.
Il malware spesso prende di mira livelli API meno recenti per aggirare la sicurezza e la privacy
che sono state introdotte nelle versioni più recenti di Android. Ad esempio:
alcune app malware utilizzano un valore targetSdkVersion pari a 22 per evitare di essere soggette
di autorizzazione di runtime introdotto nel 2015 da Android 6.0 Marshmallow (API
livello 23). Questa modifica ad Android 14 rende più difficile per il malware evitare la sicurezza
e miglioramenti della privacy.
Il tentativo di installare un'app che ha come target un livello API inferiore comporterà un
di installazione non riuscita, con il seguente messaggio visualizzato in Logcat:
INSTALL_FAILED_DEPRECATED_SDK_VERSION: App package must target at least SDK version 23, but found 7
Sui dispositivi su cui viene eseguito l'upgrade ad Android 14, tutte le app con un targetSdkVersion inferiore
rimarranno installate.
Se devi testare un'app che ha come target un livello API precedente, utilizza il seguente comando ADB:
adb install --bypass-low-target-sdk-block FILENAME.apk
I nomi dei pacchetti dei proprietari dei media potrebbero essere oscurati
The media store supports queries for the OWNER_PACKAGE_NAME column, which
indicates the app that stored a particular media file. Starting in Android
14, this value is redacted unless at least one of the following conditions is
true:
- The app that stored the media file has a package name that is always visible to other apps.
The app that queries the media store requests the
QUERY_ALL_PACKAGESpermission.
Learn more about how Android filters package visibility for privacy purposes.