La piattaforma Android 16 include modifiche al comportamento che potrebbero influire sulla tua app.
Le seguenti modifiche al comportamento si applicano a tutte le app quando vengono eseguite su Android 16,
indipendentemente da targetSdkVersion
. Devi testare la tua app e poi modificarla
in base alle necessità per supportare queste modifiche, ove applicabile.
Assicurati di esaminare anche l'elenco delle modifiche al comportamento che interessano solo le app che hanno come target Android 16.
Funzionalità di base
Android 16 (livello API 36) include le seguenti modifiche che modificano o espandono varie funzionalità di base del sistema Android.
Ottimizzazioni delle quote di JobScheduler
从 Android 16 开始,我们将根据以下因素调整常规作业和加急作业执行运行时配额:
- 应用位于哪个应用待机分桶:在 Android 16 中,系统将开始使用充足的运行时配额来强制执行处于活动状态的待机分桶。
- 如果作业在应用处于顶部状态时开始执行:在 Android 16 中,如果作业在应用对用户可见时启动,并在应用变为不可见后继续,则将遵循作业运行时配额。
- 如果作业在运行前台服务时执行:在 Android 16 中,与前台服务同时执行的作业将遵循作业运行时配额。如果您要使用作业进行用户发起的数据传输,请考虑改用用户发起的数据传输作业。
此更改会影响使用 WorkManager、JobScheduler 和 DownloadManager 调度的任务。如需调试作业停止的原因,我们建议您通过调用 WorkInfo.getStopReason()
(对于 JobScheduler 作业,请调用 JobParameters.getStopReason()
)记录作业停止的原因。
如需了解应用的状态如何影响其可使用的资源,请参阅功耗管理资源限制。如需详细了解有关延长电池续航时间的最佳实践,请参阅有关优化任务调度 API 的电池用量的指南。
我们还建议您利用 Android 16 中引入的新 JobScheduler#getPendingJobReasonsHistory
API 来了解作业未执行的原因。
测试
如需测试应用的行为,您可以启用替换某些作业配额优化,前提是应用在 Android 16 设备上运行。
如需停用强制执行“顶部状态将遵守作业运行时配额”政策,请运行以下 adb
命令:
adb shell am compat enable OVERRIDE_QUOTA_ENFORCEMENT_TO_TOP_STARTED_JOBS APP_PACKAGE_NAME
如需停用强制执行“与前台服务同时执行的作业将遵守作业运行时配额”政策,请运行以下 adb
命令:
adb shell am compat enable OVERRIDE_QUOTA_ENFORCEMENT_TO_FGS_JOBS APP_PACKAGE_NAME
如需测试特定的应用待机分桶行为,您可以使用以下 adb
命令设置应用的应用待机分桶:
adb shell am set-standby-bucket APP_PACKAGE_NAME active|working_set|frequent|rare|restricted
如需了解应用所在的应用待机分桶,您可以使用以下 adb
命令获取应用的应用待机分桶:
adb shell am get-standby-bucket APP_PACKAGE_NAME
Motivo di interruzione dei job vuoti abbandonati
Un job abbandonato si verifica quando l'oggetto JobParameters
associato al job è stato sottoposto a garbage collection, ma JobService#jobFinished(JobParameters,
boolean)
non è stato chiamato per segnalare il completamento del job. Ciò indica che il job potrebbe essere in esecuzione e essere riprogrammato senza che l'app lo sappia.
Le app che si basano su JobScheduler non mantengono un riferimento forte all'oggettoJobParameters
e ora al timeout verrà concesso il nuovo motivo di interruzione del jobSTOP_REASON_TIMEOUT_ABANDONED
, anziché STOP_REASON_TIMEOUT
.
Se si verificano spesso casi del nuovo motivo di interruzione dell'abbandono, il sistema prenderà provvedimenti per ridurre la frequenza dei job.
Le app devono utilizzare il nuovo motivo di interruzione per rilevare e ridurre i job abbandonati.
Se utilizzi WorkManager, AsyncTask o DownloadManager, non sono interessati perché queste API gestiscono il ciclo di vita dei job per conto della tua app.
Ritiro completo di JobInfo#setImportantWhileForeground
JobInfo.Builder#setImportantWhileForeground(boolean)
方法用于在调度应用位于前台或暂时豁免于后台限制时指示作业的优先级。
自 Android 12(API 级别 31)起,此方法已废弃。从 Android 16 开始,它不再有效,系统会忽略调用此方法。
此功能移除也适用于 JobInfo#isImportantWhileForeground()
。从 Android 16 开始,如果调用该方法,该方法会返回 false
。
L'ambito della priorità di trasmissione ordinata non è più globale
Android 应用可以为广播接收器定义优先级,以控制接收器接收和处理广播的顺序。对于清单声明的接收器,应用可以使用 android:priority
属性来定义优先级;对于上下文注册的接收器,应用可以使用 IntentFilter#setPriority()
API 来定义优先级。发送广播时,系统会按接收器的优先级(从高到低)将其传送给接收器。
在 Android 16 中,无法保证使用 android:priority
属性或 IntentFilter#setPriority()
在不同进程中传送广播的顺序。广播优先级仅在同一应用进程内有效,而不会跨所有进程有效。
此外,广播优先级将自动限制在 (SYSTEM_LOW_PRIORITY
+ 1, SYSTEM_HIGH_PRIORITY
- 1) 的范围内。只有系统组件才能将 SYSTEM_LOW_PRIORITY
、SYSTEM_HIGH_PRIORITY
设置为广播优先级。
如果您的应用执行以下任一操作,可能会受到影响:
- 您的应用声明了具有相同广播 intent 的多个进程,并且希望根据优先级以特定顺序接收这些 intent。
- 您的应用进程与其他进程交互,并期望以特定顺序接收广播 intent。
如果进程需要相互协调,则应使用其他协调渠道进行通信。
Modifiche interne ad ART
Android 16 includes the latest updates to the Android Runtime (ART) that improve the Android Runtime's (ART's) performance and provide support for additional Java features. Through Google Play System updates, these improvements are also available to over a billion devices running Android 12 (API level 31) and higher.
As these changes are released, libraries and app code that rely on internal structures of ART might not work correctly on devices running Android 16, along with earlier Android versions that update the ART module through Google Play system updates.
Relying on internal structures (such as non-SDK interfaces) can always lead to compatibility problems, but it's particularly important to avoid relying on code (or libraries containing code) that leverages internal ART structures, since ART changes aren't tied to the platform version the device is running on and they go out to over a billion devices through Google Play system updates.
All developers should check whether their app is impacted by testing their apps thoroughly on Android 16. In addition, check the known issues to see if your app depends on any libraries that we've identified that rely on internal ART structures. If you do have app code or library dependencies that are affected, seek public API alternatives whenever possible and request public APIs for new use cases by creating a feature request in our issue tracker.
Modalità di compatibilità con le dimensioni pagina di 16 kB
Android 15 引入了对 16 KB 内存页面的支持,以优化平台性能。Android 16 添加了兼容模式,让一些针对 4 KB 内存页面构建的应用可以在配置为 16 KB 内存页面的设备上运行。
当您的应用在搭载 Android 16 或更高版本的设备上运行时,如果 Android 检测到您的应用具有 4 KB 对齐的内存页面,则会自动使用兼容模式并向用户显示通知对话框。在 AndroidManifest.xml
中设置 android:pageSizeCompat
属性以启用向后兼容模式,将会阻止应用启动时显示对话框。如需使用 android:pageSizeCompat
属性,请使用 Android 16 SDK 编译您的应用。
为了实现最佳性能、可靠性和稳定性,应用仍应以 16 KB 对齐。如需了解详情,请参阅我们近期发布的博文,了解如何更新应用以支持 16 KB 的内存页面。

Esperienza utente e UI di sistema
Android 16 (livello API 36) include le seguenti modifiche volte a creare un'esperienza utente più coerente e intuitiva.
Ritiro degli annunci di accessibilità invasivi
Android 16 废弃了无障碍功能通告,其特征是使用 announceForAccessibility
或调度 TYPE_ANNOUNCEMENT
无障碍功能事件。这可能会给 TalkBack 和 Android 屏幕阅读器用户带来不一致的用户体验,而替代方案可以更好地满足各种 Android 辅助技术的用户需求。
替代方案示例:
- 对于窗口更改等重大界面更改,请使用
Activity.setTitle(CharSequence)
和setAccessibilityPaneTitle(java.lang.CharSequence)
。在 Compose 中,使用Modifier.semantics { paneTitle = "paneTitle" }
- 如需向用户告知关键界面的更改,请使用
setAccessibilityLiveRegion(int)
。在 Compose 中,请使用Modifier.semantics { liveRegion = LiveRegionMode.[Polite|Assertive]}
。应谨慎使用这些事件,因为它们可能会在每次更新视图时生成通知。 - 如需向用户发送错误通知,请发送类型为
AccessibilityEvent#CONTENT_CHANGE_TYPE_ERROR
的AccessibilityEvent
并设置AccessibilityNodeInfo#setError(CharSequence)
,或使用TextView#setError(CharSequence)
。
已废弃的 announceForAccessibility
API 的参考文档中包含有关建议替代方案的更多详细信息。
Supporto della navigazione con tre pulsanti
Android 16 brings predictive back support to the 3-button navigation for apps that have properly migrated to predictive back. Long-pressing the back button initiates a predictive back animation, giving you a preview of where the back swipe takes you.
This behavior applies across all areas of the system that support predictive back animations, including the system animations (back-to-home, cross-task, and cross-activity).
Supporto della navigazione con tre pulsanti
A partire da Android 16 QPR 2, Android applica automaticamente i temi alle icone delle app per creare un'esperienza coerente nella schermata Home. Ciò si verifica se un'app non fornisce la propria icona dell'app a tema. Le app possono controllare il design dell'icona dell'app a tema includendo un livello monocromatico nell'icona adattiva e visualizzando l'aspetto dell'icona dell'app in Android Studio.
Fattori di forma dei dispositivi
Android 16 (livello API 36) include le seguenti modifiche per le app quando vengono proiettate sui display dai proprietari di dispositivi virtuali.
Override del proprietario del dispositivo virtuale
虚拟设备所有者是创建和管理虚拟设备的受信任应用或特权应用。虚拟设备所有者在虚拟设备上运行应用,然后将应用投影到远程设备的显示屏上,例如个人电脑、虚拟现实设备或车载信息娱乐系统。虚拟设备所有者位于本地设备上,例如手机。

按应用替换项
在搭载 Android 16(API 级别 36)的设备上,虚拟设备所有者可以替换其管理的特定虚拟设备上的应用设置。例如,为了改进应用布局,虚拟设备所有者在将应用投影到外部显示屏上时,可以忽略屏幕方向、宽高比和可调整大小性限制。
常见的重大更改
Android 16 行为可能会影响应用在汽车显示屏或 Chromebook 等大屏幕设备上的界面,尤其是那些专为竖屏小显示屏设计的布局。如需了解如何让应用适应所有设备类型,请参阅关于自适应布局。
参考编号
Sicurezza
Android 16 (livello API 36) include modifiche che promuovono la sicurezza del sistema per proteggere app e utenti da app dannose.
Maggiore sicurezza contro gli attacchi di reindirizzamento degli intent
Android 16 提供了针对一般 Intent
重定向攻击的默认安全性,并且只需进行最低限度的兼容性更改和开发者更改。
我们正在推出默认安全强化解决方案,以应对重定向漏洞。Intent
在大多数情况下,使用 intent 的应用通常不会遇到任何兼容性问题;我们在整个开发过程中收集了指标,以监控哪些应用可能会出现中断。
当攻击者可以部分或完全控制用于在存在漏洞的应用上下文中启动新组件的 intent 内容时,Android 中就会出现 intent 重定向问题,而受害应用会在(“顶级”)Intent 的 extras 字段中启动不可信的子级 intent。这可能会导致攻击者应用在受害者应用的上下文中启动私有组件、触发特权操作或获得对敏感数据的 URI 访问权限,从而可能导致数据盗窃和任意代码执行。
选择停用 intent 重定向处理
Android 16 引入了一项新 API,允许应用选择停用启动安全保护功能。在默认安全行为会干扰正当应用用例的特定情况下,这可能是必要的。
对于针对 Android 16(API 级别 36)SDK 或更高版本进行编译的应用
您可以直接对 Intent 对象使用 removeLaunchSecurityProtection()
方法。
val i = intent
val iSublevel: Intent? = i.getParcelableExtra("sub_intent")
iSublevel?.removeLaunchSecurityProtection() // Opt out from hardening
iSublevel?.let { startActivity(it) }
对于针对 Android 15(API 级别 35)或更低版本进行编译的应用
虽然不建议这样做,但您可以使用反射来访问 removeLaunchSecurityProtection()
方法。
val i = intent
val iSublevel: Intent? = i.getParcelableExtra("sub_intent", Intent::class.java)
try {
val removeLaunchSecurityProtection = Intent::class.java.getDeclaredMethod("removeLaunchSecurityProtection")
removeLaunchSecurityProtection.invoke(iSublevel)
} catch (e: Exception) {
// Handle the exception, e.g., log it
} // Opt-out from the security hardening using reflection
iSublevel?.let { startActivity(it) }
Le app complementari non ricevono più notifiche relative ai timeout di rilevamento
Android 16 introduce un nuovo comportamento durante il percorso di accoppiamento del dispositivo complementare per proteggere la privacy della posizione dell'utente dalle app dannose. Tutte le app complementari in esecuzione su Android 16 non ricevono più una notifica diretta del timeout di rilevamento utilizzando RESULT_DISCOVERY_TIMEOUT
. L'utente viene invece informato degli eventi di timeout con una finestra di dialogo visiva. Quando l'utente chiude la finestra di dialogo, l'app viene avvisata dell'errore di associazione con RESULT_USER_REJECTED
.
La durata della ricerca è stata estesa rispetto ai 20 secondi iniziali e la ricerca del dispositivo può essere interrotta dall'utente in qualsiasi momento durante la ricerca. Se viene rilevato almeno un dispositivo nei primi 20 secondi dall'avvio della ricerca, il CDM interrompe la ricerca di altri dispositivi.
Connettività
Android 16 (livello API 36) include le seguenti modifiche nello stack Bluetooth per migliorare la connettività con i dispositivi periferici.
Gestione migliorata della perdita di obbligazioni
从 Android 16 开始,蓝牙堆栈已更新,以便在检测到远程配对丢失时提高安全性和用户体验。以前,系统会自动解除配对并启动新的配对流程,这可能会导致意外重新配对。在许多情况下,我们发现应用未以一致的方式处理债券损失事件。
为了统一体验,Android 16 改进了系统的绑定丢失处理。如果之前配对的蓝牙设备在重新连接时无法进行身份验证,系统会断开关联,保留本地配对信息,并显示系统对话框,告知用户配对已断开并指示他们重新配对。