A plataforma Android 16 inclui mudanças de comportamento que podem afetar seu app.
As mudanças de comportamento a seguir se aplicam a todos os apps quando executados no Android 16,
independente da targetSdkVersion
. Teste o app e modifique-o
conforme necessário para oferecer suporte a essas mudanças, quando aplicável.
Consulte também a lista de mudanças de comportamento que afetam apenas os apps destinados ao Android 16.
Principal recurso
O Android 16 (nível 36 da API) inclui as seguintes mudanças que modificam ou expandem vários recursos principais do sistema Android.
Otimizações de cota do JobScheduler
A partir do Android 16, estamos ajustando a cota de execução de jobs regulares e acelerados com base nos seguintes fatores:
- Em qual bucket de espera do app o aplicativo está: no Android 16, os buckets de espera ativos vão começar a ser aplicados por uma cota de tempo de execução generosa.
- Se o job iniciar a execução enquanto o app estiver em um estado superior: no Android 16, os jobs iniciados enquanto o app está visível para o usuário e continuam depois que o app fica invisível vão aderir à cota de execução do job.
- Se o job estiver sendo executado enquanto um serviço em primeiro plano é executado: no Android 16, os jobs que estiverem sendo executados simultaneamente a um serviço em primeiro plano vão aderir à cota de execução do job. Se você estiver usando jobs para transferência de dados iniciada pelo usuário, considere usar jobs de transferência de dados iniciada pelo usuário.
Essa mudança afeta as tarefas programadas usando o WorkManager, o JobScheduler e o
DownloadManager. Para depurar o motivo da interrupção de um job, recomendamos registrar o motivo
chamando WorkInfo.getStopReason()
. Para
jobs do JobScheduler, chame JobParameters.getStopReason()
.
Para saber como o estado do app afeta os recursos que ele pode usar, consulte Limites de recursos de gerenciamento de energia. Para mais informações sobre as práticas recomendadas para otimizar a bateria, consulte as orientações sobre como otimizar o uso da bateria para APIs de programação de tarefas.
Também recomendamos aproveitar a nova
API JobScheduler#getPendingJobReasonsHistory
introduzida no
Android 16 para entender por que um job não foi executado.
Teste
Para testar o comportamento do app, ative a substituição de determinadas otimizações de cota de jobs, desde que o app esteja sendo executado em um dispositivo Android 16.
Para desativar a aplicação de "o estado principal vai aderir à cota de execução do job", execute o
seguinte comando adb
:
adb shell am compat enable OVERRIDE_QUOTA_ENFORCEMENT_TO_TOP_STARTED_JOBS APP_PACKAGE_NAME
Para desativar a aplicação de "jobs que estão sendo executados simultaneamente a um
serviço em primeiro plano vão aderir à cota de execução do job", execute o seguinte
comando adb
:
adb shell am compat enable OVERRIDE_QUOTA_ENFORCEMENT_TO_FGS_JOBS APP_PACKAGE_NAME
Para testar o comportamento de um bucket de espera de app, defina o bucket
do app usando o comando adb
a seguir:
adb shell am set-standby-bucket APP_PACKAGE_NAME active|working_set|frequent|rare|restricted
Para entender o bucket de espera do app em que seu app está, é possível acessar o bucket
de espera do app usando o comando adb
a seguir:
adb shell am get-standby-bucket APP_PACKAGE_NAME
Motivo de interrupção de jobs vazios abandonados
An abandoned job occurs when the JobParameters
object associated with the job
has been garbage collected, but JobService#jobFinished(JobParameters,
boolean)
has not been called to signal job completion. This indicates that
the job may be running and being rescheduled without the app's awareness.
Apps that rely on JobScheduler, don't maintain a strong reference to the
JobParameters
object, and timeout will now be granted the new job stop reason
STOP_REASON_TIMEOUT_ABANDONED
, instead of STOP_REASON_TIMEOUT
.
If there are frequent occurrences of the new abandoned stop reason, the system will take mitigation steps to reduce job frequency.
Apps should use the new stop reason to detect and reduce abandoned jobs.
If you're using WorkManager, AsyncTask, or DownloadManager, you aren't impacted because these APIs manage the job lifecycle on your app's behalf.
Suspensão total de JobInfo#setImportantWhileForeground
JobInfo.Builder#setImportantWhileForeground(boolean)
方法用于在调度应用位于前台或暂时豁免于后台限制时指示作业的优先级。
自 Android 12(API 级别 31)起,此方法已废弃。从 Android 16 开始,它不再有效,系统会忽略调用此方法。
此功能移除也适用于 JobInfo#isImportantWhileForeground()
。从 Android 16 开始,如果调用该方法,该方法会返回 false
。
O escopo de prioridade de transmissão ordenada não é mais global
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。
如果进程需要相互协调,则应使用其他协调渠道进行通信。
Alterações internas do ART
Android 16 包含 Android 运行时 (ART) 的最新更新,这些更新可提升 Android 运行时 (ART) 的性能,并支持更多 Java 功能。通过 Google Play 系统更新,搭载 Android 12(API 级别 31)及更高版本的 10 亿多部设备也将受益于这些改进。
发布这些变更后,依赖于 ART 内部结构的库和应用代码在搭载 Android 16 的设备以及通过 Google Play 系统更新来更新 ART 模块的较低 Android 版本上可能无法正常运行。
依赖于内部结构(例如非 SDK 接口)始终会导致兼容性问题,但避免依赖于利用内部 ART 结构的代码(或包含代码的库)尤为重要,因为 ART 更改与设备所运行的平台版本无关,并且会通过 Google Play 系统更新推送到超过 10 亿部设备。
所有开发者都应在 Android 16 上对其应用进行全面测试,以检查其应用是否受到影响。此外,请查看已知问题,了解您的应用是否依赖于我们发现的任何依赖于内部 ART 结构的库。如果您的应用代码或库依赖项受到影响,请尽可能寻找公共 API 替代方案,并在问题跟踪器中创建功能请求,为新用例请求公共 API。
Modo de compatibilidade de tamanho de página de 16 KB
Android 15 introduced support for 16 KB memory pages to optimize performance of the platform. Android 16 adds a compatibility mode, allowing some apps built for 4 KB memory pages to run on a device configured for 16 KB memory pages.
When your app is running on a device with Android 16 or higher, if Android
detects that your app has 4 KB aligned memory pages, it automatically uses
compatibility mode and display a notification dialog to the user. Setting the
android:pageSizeCompat
property in the AndroidManifest.xml
to enable the
backwards compatibility mode will prevent the display of the dialog when your
app launches. To use the android:pageSizeCompat
property, compile your app
using the Android 16 SDK.
For best performance, reliability, and stability, your app should still be 16 KB aligned. Check out our recent blog post on updating your apps to support 16 KB memory pages for more details.

Experiência do usuário e interface do sistema
O Android 16 (nível 36 da API) inclui as seguintes mudanças, que têm como objetivo criar uma experiência do usuário mais consistente e intuitiva.
Descontinuação dos avisos de acessibilidade que causam interrupção
Android 16 deprecates accessibility announcements, characterized by the use of
announceForAccessibility
or the dispatch of
TYPE_ANNOUNCEMENT
accessibility events. These can create
inconsistent user experiences for users of TalkBack and Android's screen reader,
and alternatives better serve a broader range of user needs across a variety of
Android's assistive technologies.
Examples of alternatives:
- For significant UI changes like window changes, use
Activity.setTitle(CharSequence)
andsetAccessibilityPaneTitle(java.lang.CharSequence)
. In Compose, useModifier.semantics { paneTitle = "paneTitle" }
- To inform the user of changes to critical UI, use
setAccessibilityLiveRegion(int)
. In Compose, useModifier.semantics { liveRegion = LiveRegionMode.[Polite|Assertive]}
. These should be used sparingly as they may generate announcements every time a View is updated. - To notify users about errors, send an
AccessibilityEvent
of typeAccessibilityEvent#CONTENT_CHANGE_TYPE_ERROR
and setAccessibilityNodeInfo#setError(CharSequence)
, or useTextView#setError(CharSequence)
.
The reference documentation for the deprecated
announceForAccessibility
API includes more details about
suggested alternatives.
Suporte à navegação com três botões
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).
Formatos de dispositivo
O Android 16 (nível 36 da API) inclui as seguintes mudanças para apps quando projetados em telas por proprietários de dispositivos virtuais.
Modificações do proprietário do dispositivo virtual
虚拟设备所有者是创建和管理虚拟设备的可信或特权应用。虚拟设备所有者可以在虚拟设备上运行应用,然后将应用投影到远程设备(例如个人计算机、虚拟现实设备或汽车信息娱乐系统)的显示屏上。虚拟设备所有者位于本地设备(例如手机)上。

按应用替换项
在搭载 Android 16(API 级别 36)的设备上,虚拟设备所有者可以在虚拟设备所有者管理的部分虚拟设备上替换应用设置。例如,为了改进应用布局,虚拟设备所有者可以在将应用投影到外部显示屏时忽略屏幕方向、宽高比和可调整大小限制。
常见的破坏性更改
Android 16 中的此行为可能会影响应用在汽车显示屏或 Chromebook 等大屏幕设备上的界面,尤其是针对纵向小屏幕设计的布局。如需了解如何让应用适应所有设备类型,请参阅自适应布局简介。
参考文档
Segurança
O Android 16 (nível 36 da API) inclui mudanças que promovem a segurança do sistema para ajudar a proteger apps e usuários contra apps maliciosos.
Melhoria da segurança contra ataques de redirecionamento de intent
Android 16 提供了针对常规 Intent
重定向攻击的默认安全防护,并且所需的兼容性和开发者更改最少。
我们将默认针对 Intent
重定向漏洞引入安全增强解决方案。在大多数情况下,使用 intent 的应用通常不会遇到任何兼容性问题;我们在整个开发过程中收集了指标,以监控哪些应用可能会出现故障。
当攻击者部分或完全控制用于在存在漏洞的应用上下文中启动新组件的 intent 内容时,就会出现 Android 中的 intent 重定向,而受害应用会在 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) }
Os apps complementares não são mais notificados sobre o tempo limite de descoberta
Android 16 在配套设备配对流程期间引入了一种新行为,以防恶意应用侵犯用户的位置信息隐私。在 Android 16 上运行的所有配套应用都不再直接通过 RESULT_DISCOVERY_TIMEOUT
收到发现超时通知。而是通过可视对话框通知用户超时事件。当用户关闭对话框时,系统会通过 RESULT_USER_REJECTED
提醒应用关联失败。
搜索时长也从原来的 20 秒延长到了 30 秒,并且用户可以在搜索期间的任何时间停止设备发现。如果在开始搜索的前 20 秒内发现了至少 1 部设备,CDM 会停止搜索其他设备。
Conectividade
O Android 16 (nível 36 da API) inclui as seguintes mudanças na pilha de Bluetooth para melhorar a conectividade com dispositivos periféricos.
Melhoria no tratamento de perdas de títulos
Starting in Android 16, the Bluetooth stack has been updated to improve security and user experience when a remote bond loss is detected. Previously, the system would automatically remove the bond and initiate a new pairing process, which could lead to unintentional re-pairing. We have seen in many instances apps not taking care of the bond loss event in a consistent way.
To unify the experience, Android 16 improved the bond loss handling to the system. If a previously bonded Bluetooth device could not be authenticated upon reconnection, the system will disconnect the link, retain local bond information, and display a system dialog informing users of the bond loss and directing them to re-pair.