Android 14 platformu, uygulamanızı etkileyebilecek davranış değişiklikleri içerir.
Aşağıdaki davranış değişiklikleri, targetSdkVersion değerinden bağımsız olarak Android 14'te çalışan tüm uygulamalar için geçerlidir. Uygulamanızı test etmeli ve uygun olduğu durumlarda bunları düzgün şekilde desteklemek için gerektiği gibi değiştirmelisiniz.
Yalnızca Android 14'ü hedefleyen uygulamaları etkileyen davranış değişiklikleri listesini de incelemeyi unutmayın.
Temel işlevler
Tam zamanlı alarm planlama isteği varsayılan olarak reddedilir
Tam alarmlar, kullanıcı tarafından istenen bildirimler veya tam olarak belirli bir zamanda yapılması gereken işlemler için kullanılır. Android 14'ten itibaren SCHEDULE_EXACT_ALARM izni, Android 13 ve sonraki sürümleri hedefleyen yeni yüklenen uygulamaların çoğuna artık önceden verilmemektedir. Bu izin varsayılan olarak reddedilir.
Tam alarm planlama izninde yapılan değişiklikler hakkında daha fazla bilgi edinin.
Bağlamda kayıtlı yayınlar, uygulamalar önbelleğe alınırken sıraya alınır.
在 Android 14 中,当应用处于缓存状态时,系统可以将上下文注册的广播放入队列中。这与 Android 12(API 级别 31)为异步 binder 事务引入的队列行为类似。在清单中声明的广播不会加入队列,并且应用会从缓存状态中移除以进行广播传递。
当应用离开缓存状态(例如返回前台)时,系统会传递所有已加入队列的广播。某些广播的多个实例 可能会合并为一个广播。取决于其他因素,如系统 运行状况,则可能会从缓存状态中移除应用,以及之前排队 广播。
Uygulamalar yalnızca kendi arka plan işlemlerini sonlandırabilir
从 Android 14 开始,当您的应用调用 killBackgroundProcesses() 时,该 API 只能终止您自己应用的后台进程。
如果您传入另一个应用的软件包名称,此方法对该应用的后台进程没有影响,并且 Logcat 中会显示以下消息:
Invalid packageName: com.example.anotherapp
您的应用不应使用 killBackgroundProcesses() API,也不得以其他方式尝试影响其他应用的进程生命周期,即使在旧版操作系统上也是如此。Android 旨在让缓存应用在后台运行,并在系统需要内存时自动终止它们。如果您的应用会不必要地终止其他应用,则由于之后需要完全重启这些应用,因此可能会降低系统性能并增加耗电量,这比恢复现有缓存应用所消耗的资源要多得多。
MTU, MTU isteyen ilk GATT istemcisi için 517 olarak ayarlanır.
Starting from Android 14, the Android Bluetooth stack more strictly adheres to
Version 5.2 of the Bluetooth Core Specification and requests
the BLE ATT MTU to 517 bytes when the first GATT client requests an MTU using
the BluetoothGatt#requestMtu(int) API, and disregards all subsequent MTU
requests on that ACL connection.
To address this change and make your app more robust, consider the following options:
- Your peripheral device should respond to the Android device's MTU request
with a reasonable value that can be accommodated by the peripheral. The
final negotiated value will be a minimum of the Android requested value and
the remote provided value (for example,
min(517, remoteMtu))- Implementing this fix could require a firmware update for peripheral
- Alternatively, limit your GATT characteristic writes based on the minimum
between the known supported value of your peripheral and the received MTU
change
- A reminder that you should reduce 5 bytes from the supported size for the headers
- For example:
arrayMaxLength = min(SUPPORTED_MTU, GATT_MAX_ATTR_LEN(517)) - 5
Bir uygulamanın kısıtlanmış bekleme grubuna yerleştirilebileceği yeni neden
Android 14 引入了一种可将应用放入受限待机模式存储分区的新原因。由于 onStartJob、onStopJob 或 onBind 方法超时,应用的作业多次触发 ANR 错误。(如需了解对 onStartJob 和 onStopJob 的更改,请参阅 JobScheduler 强化了回调和网络行为。)
如需跟踪应用是否已进入受限待机分桶,我们建议您在作业执行时使用 API UsageStatsManager.getAppStandbyBucket() 进行日志记录,或在应用启动时使用 UsageStatsManager.queryEventsForSelf() 进行日志记录。
mlock 64 KB ile sınırlıdır
在 Android 14(API 级别 34)及更高版本中,平台将可使用 mlock() 锁定的最大内存量减少到每个进程 64 KB。在之前的版本中,每个进程的上限为 64 MB。此限制有助于更好地管理应用和系统的内存。为了在各种设备上提供更一致的体验,Android 14 针对兼容设备上的新 mlock() 限制添加了一项新的 CTS 测试。
Sistem, önbelleğe alınmış uygulama kaynak kullanımını zorunlu kılar
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.
Kullanıcı deneyimi
Kullanıcıların kapatılamayan bildirimlerle ilgili deneyiminde yapılan değişiklikler
如果您的应用向用户显示不可关闭的前台通知,请注意:Android 14 已更改此行为,允许用户关闭此类通知。
这项变更适用于阻止用户关闭前台的应用
将 Notification.FLAG_ONGOING_EVENT 设置为
Notification.Builder#setOngoing(true) 或
NotificationCompat.Builder#setOngoing(true)。FLAG_ONGOING_EVENT 的行为已发生变化,使用户实际上能够关闭此类通知。
在以下情况下,此类通知仍不可关闭:
- 当手机处于锁定状态时
- 如果用户选择全部清除通知操作(有助于防止意外关闭)
此外,这一新行为不适用于以下用例中的通知:
CallStyle条通知- 企业设备政策控制器 (DPC) 和支持软件包
- 媒体通知
- 默认的搜索选择器软件包
Veri güvenliği bilgileri daha görünür
为了加强用户隐私保护,Android 14 增加了系统显示您在 Play 管理中心表单中声明的信息的位置数量。目前,用户可以在 Google Play 中的应用详情的数据安全部分查看此信息。
我们建议您查看应用的位置数据分享政策,并花一点时间对应用的 Google Play“数据安全”部分进行任何适用的更新。
如需了解详情,请参阅有关如何在 Android 14 上以更显眼的方式显示数据安全信息的指南。
Erişilebilirlik
%200'e kadar doğrusal olmayan yazı tipi ölçeklendirme
从 Android 14 开始,系统支持将字体放大至最高 200%,为用户提供更多无障碍选项。
如果您已使用可缩放像素 (sp) 单位来定义文本大小,这项更改可能不会对您的应用产生太大影响。不过,您应在启用最大字号 (200%) 的情况下执行界面测试,确保应用能够在不影响易用性的情况下适应较大的字号。
Güvenlik
Minimum yüklenebilir hedef API düzeyi
从 Android 14 开始,targetSdkVersion 低于 23 的应用无法安装。要求应用满足这些最低目标 API 级别要求有助于提高用户的安全性和隐私性。
恶意软件通常会以较旧的 API 级别为目标平台,以绕过在较新版本 Android 中引入的安全和隐私保护机制。例如,有些恶意软件应用使用 targetSdkVersion 22,以避免受到 Android 6.0 Marshmallow(API 级别 23)在 2015 年引入的运行时权限模型的约束。这项 Android 14 变更使恶意软件更难以规避安全和隐私权方面的改进限制。尝试安装以较低 API 级别为目标平台的应用将导致安装失败,并且 Logcat 中会显示以下消息:
INSTALL_FAILED_DEPRECATED_SDK_VERSION: App package must target at least SDK version 23, but found 7
在升级到 Android 14 的设备上,targetSdkVersion 低于 23 的所有应用都将继续保持安装状态。
如果您需要测试以旧版 API 级别为目标平台的应用,请使用以下 ADB 命令:
adb install --bypass-low-target-sdk-block FILENAME.apk
Medya sahibinin paket adları sansürlenebilir
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.