Android 14 為開發人員推出了強大的功能和 API。以下各節可協助您瞭解應用程式功能,並開始使用相關的 API。
如需新增、修改及移除 API 的詳細清單,請參閱 API 差異比較表。如要進一步瞭解新增的 API,請參閱 Android API 參考資料。在 Android 14 中,請尋找 API 級別 34 新增的 API。如要瞭解平台變更可能對應用程式造成的影響,請務必查看指定 Android 14 的應用程式和所有應用程式的 Android 14 行為變更。
國際化
個別應用程式語言偏好
Android 14 進一步延伸 Android 13 (API 級別 33) 所推出的個別應用程式語言功能,並新增多項功能:
自動產生應用程式的
localeConfig
:自 Android Studio Giraffe Canary 7 和 AGP 8.1.0-alpha07 起,您可以將應用程式設為自動支援個別應用程式語言偏好設定。Android Gradle 外掛程式會根據您的專案資源產生LocaleConfig
檔案,並在最終資訊清單檔案中為該檔案新增參照,為您省去手動建立或更新檔案的需求。AGP 會使用應用程式模組res
資料夾中的資源和任何程式庫模組依附元件,以決定要納入LocaleConfig
檔案的語言代碼。應用程式
localeConfig
的動態更新:請使用 法LocaleManager
中的setOverrideLocaleConfig()
和getOverrideLocaleConfig()
方法,以動態方式更新應用程式在裝置的系統設定中的支援語言清單。如果應用程式使用伺服器端推送進行本地化,則可利用此彈性自訂各區域的支援語言清單、執行 A/B 實驗,或提供更新的語言代碼清單。輸入法編輯器 (IME) 的應用程式語言瀏覽權限:輸入法編輯器可透過
getApplicationLocales()
方法檢查當前應用程式的語言,並和輸入法編輯器的語言進行比對。
文法轉變 API
30 億人使用性別化語言:即名詞、動詞、形容詞和介系詞會隨著交談或談論對象或目標的性別,而有不同變化形式的文法類別語言。一般來說,許多性別化語言都會使用陽性文法性別做為預設或通用性別。
若以錯誤的文法性別稱呼使用者,例如:以陽性文法性別稱呼女性,可能會對其表現及態度產生負面影響。相較之下,如果使用者介面的用語正確反映了使用者的文法性別,便可提高使用者參與度,同時提供更個人化且更自然親切的使用者體驗。
為了協助你針對使用文法性別的語言,建構以使用者為中心的使用者介面,Android 14 採用了文法轉變 API,可讓你新增對文法性別的支援,而不必重構應用程式。
地區偏好設定
Regional preferences enable users to personalize temperature units, the first day of the week, and numbering systems. A European living in the United States might prefer temperature units to be in Celsius rather than Fahrenheit and for apps to treat Monday as the beginning of the week instead of the US default of Sunday.
New Android Settings menus for these preferences provide users with a
discoverable and centralized location to change app preferences. These
preferences also persist through backup and restore. Several APIs and
intents—such as
getTemperatureUnit
and
getFirstDayOfWeek
—
grant your app read access to user preferences, so your app can adjust how it
displays information. You can also register a
BroadcastReceiver
on
ACTION_LOCALE_CHANGED
to handle locale configuration changes when regional preferences change.
To find these settings, open the Settings app and navigate to System > Languages & input > Regional preferences.


無障礙設定
非線性字型縮放至 200%
自 Android 14 起,系統將支援高達 200% 的字型縮放功能,提供 視力不佳的使用者提供額外的無障礙服務選項, 無障礙內容規範 (WCAG)。
為避免畫面上的大型文字元素縮放過大,系統會採用系統做法 會套用非線性縮放曲線此縮放策略指的是大型文字 因此未像較小的文字一樣縮放非線性字型縮放功能 保留不同大小元素之間的比例階層 減少線性文字縮放為高角度的問題 (例如 截斷或因為超大型顯示而難以閱讀的文字 大小)。
使用非線性字型縮放測試應用程式

如果您已使用經過調整像素 (sp) 的單位定義文字大小,系統會自動將這些額外選項和縮放改善功能套用至應用程式中的文字。不過,您仍應啟用最大字型大小 (200%) 執行 UI 測試,確保應用程式能正確套用字型大小,並在不影響可用性的情況下,因應更大的字型大小。
如要啟用 200% 的字型大小,請按照下列步驟操作:
- 開啟「設定」應用程式,然後依序前往「無障礙中心」>「無障礙設定」顯示大小和 文字。
- 在「字型大小」選項中,輕觸加號 (+) 圖示,直到達字型大小上限為止,如本節隨附的圖片所示。
使用經過調整像素 (sp) 的單位處理文字大小
請記得一律以 sp 單位為單位指定文字大小。時間 應用程式使用 sp 單位,Android 可套用使用者偏好的文字大小 彈性調整資源配置
請勿使用 sp 單位做為邊框間距,也不應以隱含邊框間距來定義檢視畫面高度: 非線性字型縮放 sp 尺寸比例可能不一致,因此 4sp + 20sp 不一定等於 24sp。
轉換經過調整像素 (sp) 的單位
使用 TypedValue.applyDimension()
將 sp 單位轉換為像素,並使用 TypedValue.deriveDimension()
將像素轉換為 sp。這些方法會自動套用至適當的非線性縮放曲線。
避免使用硬式編碼方程式
Configuration.fontScale
或
DisplayMetrics.scaledDensity
。因為字型縮放功能
非線性,scaledDensity
欄位已不準確。由於字型不再以單一標量值進行縮放,因此 fontScale
欄位應僅用於提供資訊。
使用 sp 單位處理 lineHeight
一律改用 sp 單位定義 android:lineHeight
因此,行高會隨著文字縮放。否則,如果您的文字
是 sp,但 lineHeight
的單位為 dp 或 px,則不會縮放,看起來會受到限制。
TextView 會自動修正 lineHeight
,使其符合您的預期
只有在 textSize
和 lineHeight
都同時符合時,比例才會保留
以 sp 為單位定義。
相機和媒體
圖片的 Ultra HDR

Android 14 adds support for High Dynamic Range (HDR) images that retain more of the information from the sensor when taking a photo, which enables vibrant colors and greater contrast. Android uses the Ultra HDR format, which is fully backward compatible with JPEG images, allowing apps to seamlessly interoperate with HDR images, displaying them in Standard Dynamic Range (SDR) as needed.
Rendering these images in the UI in HDR is done automatically by the framework
when your app opts in to using HDR UI for its Activity Window, either through a
manifest entry or at runtime by calling
Window.setColorMode()
. You can also capture compressed Ultra
HDR still images on supported devices. With more colors recovered
from the sensor, editing in post can be more flexible. The
Gainmap
associated with Ultra HDR images can be used to render
them using OpenGL or Vulkan.
相機擴充功能中的變焦、對焦、後製預覽等功能
Android 14 會升級及改善相機擴充功能,讓應用程式能夠處理更長的處理時間,在支援裝置上使用低光源攝影等需要大量運算的演算法,改善圖片品質。這些功能可讓使用者在使用相機擴充功能時,享有更完善的體驗。這些改善措施包括:
- 動態靜態攝影處理延遲時間預估功能會根據目前的場景和環境條件,提供更準確的靜態攝影延遲時間預估值。呼叫
CameraExtensionSession.getRealtimeStillCaptureLatency()
取得具有兩種延遲時間估計方法的StillCaptureLatency
物件。getCaptureLatency()
方法會傳回onCaptureStarted
和onCaptureProcessStarted()
之間的預估延遲時間,而getProcessingLatency()
方法會傳回onCaptureProcessStarted()
和可用的最終處理影格之間的預估延遲時間。 - 支援擷取進度回呼,讓應用程式可顯示長時間執行的靜態影像處理作業目前的進度。您可以檢查
CameraExtensionCharacteristics.isCaptureProcessProgressAvailable
是否支援這項功能,如果可以,請實作onCaptureProcessProgressed()
回呼,其中進度 (從 0 到 100) 會做為參數傳入。 擴充功能專屬中繼資料,例如用於調整擴充功能效果數量的
CaptureRequest.EXTENSION_STRENGTH
,例如使用EXTENSION_BOKEH
調整背景模糊效果的數量。相機擴充功能中的靜態影像拍攝功能,可提供比最終圖片更少經過處理的圖片。如果擴充功能導致處理延遲時間增加,您可以提供後端圖片做為預留位置,以改善使用者體驗,並在稍後切換為最終圖片。您可以查看
CameraExtensionCharacteristics.isPostviewAvailable
是否支援這項功能。接著,您可以將OutputConfiguration
傳遞至ExtensionSessionConfiguration.setPostviewOutputConfiguration
。支援
SurfaceView
,可提供更經過最佳化且省電的預覽算繪路徑。支援在擴充功能使用期間輕觸聚焦和縮放功能。
感應器內變焦
When REQUEST_AVAILABLE_CAPABILITIES_STREAM_USE_CASE
in
CameraCharacteristics
contains
SCALER_AVAILABLE_STREAM_USE_CASES_CROPPED_RAW
, your app
can use advanced sensor capabilities to give a cropped RAW stream the same
pixels as the full field of view by using a CaptureRequest
with a RAW target that has stream use case set to
CameraMetadata.SCALER_AVAILABLE_STREAM_USE_CASES_CROPPED_RAW
.
By implementing the request override controls, the updated camera gives users
zoom control even before other camera controls are ready.
無損 USB 音訊
Android 14 支援無損音訊格式,可透過 USB 有線耳機提供頂級音響體驗。您可以查詢 USB 裝置的偏好混合器屬性、註冊偏好混合器屬性變更的事件監聽器,以及使用 AudioMixerAttributes
類別設定混合器屬性。這個類別代表音訊調音器的格式,例如通道遮罩、取樣率和行為。這個類別可讓您直接傳送音訊,不必進行混合、音量調整或處理效果。
開發人員工作效率和工具
Credential Manager
Android 14 會新增 Credential Manager 做為平台 API,並透過使用 Google Play 服務的 Jetpack 程式庫,進一步支援 Android 4.4 (API 級別 19) 裝置。Credential Manager 的目標是透過 API 協助使用者輕鬆登入,這些 API 會透過使用者設定的憑證提供者擷取及儲存憑證。Credential Manager 可在單一 API 中支援多種登入方式,包括使用者名稱和密碼、密碼金鑰,以及聯合登入解決方案 (例如使用 Google 帳戶登入)。
密碼金鑰具有許多優點,舉例來說,密碼金鑰採用業界標準,可在不同作業系統和瀏覽器環境中運作,也能與網站和應用程式搭配使用。
如需更多資訊,請參閱 Credential Manager 和密碼金鑰說明文件,以及Credential Manager 和密碼金鑰相關網誌文章。
Health Connect
Health Connect is an on-device repository for user health and fitness data. It allows users to share data between their favorite apps, with a single place to control what data they want to share with these apps.
On devices running Android versions prior to Android 14, Health Connect is available to download as an app on the Google Play store. Starting with Android 14, Health Connect is part of the platform and receives updates through Google Play system updates without requiring a separate download. With this, Health Connect can be updated frequently, and your apps can rely on Health Connect being available on devices running Android 14 or higher. Users can access Health Connect from the Settings in their device, with privacy controls integrated into the system settings.


Health Connect includes several new features in Android 14, such as exercise routes, allowing users to share a route of their workout which can be visualized on a map. A route is defined as a list of locations saved within a window of time, and your app can insert routes into exercise sessions, tying them together. To ensure that users have complete control over this sensitive data, users must allow sharing individual routes with other apps.
For more information, see the Health Connection documentation and the blogpost on What's new in Android Health.
OpenJDK 17 更新
Android 14 continues the work of refreshing Android's core libraries to align with the features in the latest OpenJDK LTS releases, including both library updates and Java 17 language support for app and platform developers.
The following features and improvements are included:
- Updated approximately 300
java.base
classes to Java 17 support. - Text Blocks, which introduce multi-line string literals to the Java programming language.
- Pattern Matching for instanceof, which allows an object to
be treated as having a specific type in an
instanceof
without any additional variables. - Sealed classes, which allow you restrict which classes and interfaces can extend or implement them.
Thanks to Google Play system updates (Project Mainline), over 600 million devices are enabled to receive the latest Android Runtime (ART) updates that include these changes. This is part of our commitment to give apps a more consistent, secure environment across devices, and to deliver new features and capabilities to users independent of platform releases.
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
應用程式商店改善項目
Android 14 引進幾個 PackageInstaller
API,可讓應用程式商店改善使用者體驗。
在下載之前要求安裝核准
安裝或更新應用程式可能需要使用者核准。例如:當使用 REQUEST_INSTALL_PACKAGES
權限的安裝程式試著要安裝新的應用程式時。在先前的 Android 版本中,應用程式商店只能夠在 APK 寫入安裝工作階段,且該工作階段已履行之後,才可要求使用者核准。
自 Android 14 起,requestUserPreapproval()
方法可讓安裝程式在履行安裝工作階段之前要求使用者核准。這項改善項目讓應用程式商店將下載任何 APK 的時間延後,直到使用者核准安裝為止。此外,在使用者核准安裝後,應用程式商店可以在背景下載並安裝應用程式,避免對使用者造成困擾。
聲明日後更新的責任
setRequestUpdateOwnership()
方法可讓安裝程式向系統表示,日後為應用程式安裝的更新皆由其負責處理。這項功能可啟用更新擁有權強制執行機制,也就是只有更新擁有者才能安裝應用程式的自動更新。強制更新擁有權有助於確保使用者一律從預期的應用程式商店收到更新。
任何其他安裝程式 (包括使用 INSTALL_PACKAGES
權限的安裝程式) 都必須明確獲得使用者核准,才能安裝更新。如果使用者決定繼續執行其他來源的更新,則將失去更新擁有權。
在較不受干擾的情況下更新應用程式
一般來說,應用程式商店會希望避免更新正在使用中的應用程式,以免導致應用程式正在執行的程序終止,進而中斷使用者正在執行的操作。
自 Android 14 起,InstallConstraints
API 可讓安裝程式確保應用程式更新作業能在適當時機執行。舉例來說,應用程式商店可呼叫 commitSessionAfterInstallConstraintsAreMet()
方法,以確保只有在使用者不再與應用程式互動時才會執行更新。
順利安裝選用分割項目
使用分割 APK 時,應用程式的功能可透過個別 APK 檔案提供,而不是以單體 APK 為單位提供。分割 APK 可讓應用程式商店以最佳方式提供不同的應用程式元件。例如,應用程式商店可能會根據目標裝置的屬性進行最佳化。自 API 級別 22 推出以來,PackageInstaller
API 已支援分割。
在 Android 14 中,setDontKillApp()
方法可讓安裝程式指出在安裝新的分割項目時,不應導致應用程式執行中的處理程序終止。應用程式商店可在使用者使用應用程式時,透過此功能順利安裝應用程式的新功能。
應用程式中繼資料套件
從 Android 14 開始,Android 套件安裝程式可讓您指定應用程式中繼資料 (例如資料安全性做法),以加入 Google Play 等應用程式商店頁面。
在使用者擷取裝置螢幕畫面時偵測
To create a more standardized experience for detecting screenshots, Android 14 introduces a privacy-preserving screenshot detection API. This API lets apps register callbacks on a per-activity basis. These callbacks are invoked, and the user is notified, when the user takes a screenshot while that activity is visible.
使用者體驗
Sharesheet 自訂動作與改善排名
Android 14 updates the system sharesheet to support custom app actions and more informative preview results for users.
Add custom actions
With Android 14, your app can add custom actions to the system sharesheet it invokes.

Improve ranking of Direct Share targets
Android 14 uses more signals from apps to determine the ranking of the direct share targets to provide more helpful results for the user. To provide the most useful signal for ranking, follow the guidance for improving rankings of your Direct Share targets. Communication apps can also report shortcut usage for outgoing and incoming messages.

支援預測返回功能的內建和自訂動畫
Android 13 推出了在開發人員選項背後顯示「預測返回主畫面」動畫的功能。只要使用支援的應用程式,並啟用開發人員選項,當您執行滑動返回的操作時,系統就會顯示動畫,指出返回手勢可讓應用程式結束並返回主畫面。
Android 14 內含多項改善項目,並提供有關預測返回手勢的全新指南:
- 您可以設定
android:enableOnBackInvokedCallback=true
,選擇針對個別活動啟用預測返回系統動畫,而非針對整個應用程式。 - 我們新增了系統動畫,以配合 Android 13 的「返回主畫面」動畫。新的系統動畫具有跨活動和跨工作的特色,您只要改用預測返回功能,即可自動取得。
- 我們為底部功能表、側邊功能表和搜尋頁面新增了 Material 元件動畫。
- 我們製作了設計指南,讓您瞭解如何建立自訂的應用程式內動畫和轉場效果。
- 我們新增了 API,支援自訂的應用程式內轉換動畫:
在這個 Android 14 預先發布版本中,所有預測返回相關功能都保留在開發人員選項後方。請參閱開發人員指南,瞭解如何讓應用程式改用預測返回功能,以及如何建立自訂的應用程式內轉場效果。
大螢幕裝置製造商個別應用程式覆寫值
個別應用程式覆寫值可讓裝置製造商變更大螢幕裝置上的應用程式行為。舉例來說,即使應用程式資訊清單中已設定 resizeableActivity="false"
,FORCE_RESIZE_APP
覆寫值仍會指示系統根據螢幕尺寸調整應用程式大小 (避免大小相容性模式)。
覆寫設定的用意是改善大螢幕的使用者體驗。
新的資訊清單屬性可讓您為應用程式停用部分裝置製造商覆寫值。
大螢幕使用者個別應用程式覆寫值
個別應用程式覆寫值可變更應用程式在大螢幕裝置上的行為。舉例來說,無論應用程式設定為何,OVERRIDE_MIN_ASPECT_RATIO_LARGE
裝置製造商覆寫值都會將應用程式顯示比例設為 16:9。
在 Android 14 QPR1 中,使用者可透過新的設定選單,在大螢幕裝置上套用個別應用程式覆寫值。
應用程式分享螢幕畫面
分享應用程式畫面功能可讓使用者在錄製螢幕內容時,分享應用程式視窗,而非整個裝置畫面。
透過應用程式螢幕分享功能,系統會從共用畫面中排除狀態列、導覽列、通知和其他系統 UI 元素。只會分享所選應用程式的內容。
應用程式螢幕分享功能可讓使用者執行多個應用程式,但只分享單一應用程式的內容,進而提升工作效率和隱私權。
Pixel 8 Pro 的 Gboard 支援 LLM 智慧回覆功能
On Pixel 8 Pro devices with the December Feature Drop, developers can try out higher-quality smart replies in Gboard powered by on-device Large Language Models (LLMs) running on Google Tensor.
This feature is available as a limited preview for US English in WhatsApp, Line, and KakaoTalk. It requires using a Pixel 8 Pro device with Gboard as your keyboard.
To try it out, first enable the feature in Settings > Developer Options > AiCore Settings > Enable Aicore Persistent.
Next, open a conversation in a supported app to see LLM-powered Smart Reply in Gboard's suggestion strip in response to incoming messages.
圖形
路徑可供查詢及內插
Android 的 Path
API 是一種強大且靈活的機制,可用於建立和算繪向量圖形,並具有描邊或填入路徑、從線段或二次方或三次方曲線建構路徑、執行布林運算以取得更複雜的形狀,或同時執行所有這些操作的功能。但有一個限制,就是無法找出路徑物件中的實際內容;物件的內部部分在建立後,無法明確顯示於呼叫端。
如要建立 Path
,您必須呼叫 moveTo()
、lineTo()
和 cubicTo()
等方法,以便新增路徑區隔。不過,您無法透過對該路徑提出詢問以瞭解確切的區隔,因此必須在建立時保留該資訊。
自 Android 14 起,您便可查詢路徑,找出其中的內容。首先,您需要使用 Path.getPathIterator
API 取得 PathIterator
物件:
Kotlin
val path = Path().apply { moveTo(1.0f, 1.0f) lineTo(2.0f, 2.0f) close() } val pathIterator = path.pathIterator
Java
Path path = new Path(); path.moveTo(1.0F, 1.0F); path.lineTo(2.0F, 2.0F); path.close(); PathIterator pathIterator = path.getPathIterator();
接下來,您可以呼叫 PathIterator
逐一疊代區隔,並擷取每個區隔的所有必要資料。本範例使用封裝資料的 PathIterator.Segment
物件:
Kotlin
for (segment in pathIterator) { println("segment: ${segment.verb}, ${segment.points}") }
Java
while (pathIterator.hasNext()) { PathIterator.Segment segment = pathIterator.next(); Log.i(LOG_TAG, "segment: " + segment.getVerb() + ", " + segment.getPoints()); }
PathIterator
也提供 next()
的非分配式版本,可供您傳入緩衝區,以便保留單點資料。
內插類型是查詢 Path
資料的重要用途之一。例如,您可能想要在兩個不同路徑之間建立動畫 (或 變形)。為進一步簡化該使用情境,Android 14 也在 Path
中加入 interpolate()
方法。假設兩個路徑具有相同的內部結構,interpolate()
方法會使用該內插結果建立新的 Path
。此範例會傳回形狀介於 path
和 otherPath
之間半行 (0 .5 的線性內插) 的路徑:
Kotlin
val interpolatedResult = Path() if (path.isInterpolatable(otherPath)) { path.interpolate(otherPath, .5f, interpolatedResult) }
Java
Path interpolatedResult = new Path(); if (path.isInterpolatable(otherPath)) { path.interpolate(otherPath, 0.5F, interpolatedResult); }
Jetpack graphics-path 程式庫也會為舊版 Android 啟用類似的 API。
使用頂點和片段著色器的自訂網格
Android has long supported drawing triangle meshes with custom shading, but the input mesh format has been limited to a few predefined attribute combinations. Android 14 adds support for custom meshes, which can be defined as triangles or triangle strips, and can, optionally, be indexed. These meshes are specified with custom attributes, vertex strides, varying, and vertex and fragment shaders written in AGSL.
The vertex shader defines the varyings, such as position and color, while the
fragment shader can optionally define the color for the pixel, typically by
using the varyings created by the vertex shader. If color is provided by the
fragment shader, it is then blended with the current Paint
color using the blend mode selected when
drawing the mesh. Uniforms can be passed
into the fragment and vertex shaders for additional flexibility.
Canvas 的硬體緩衝區轉譯器
為協助使用 Android 的 Canvas
API 以硬體加速繪製至 HardwareBuffer
,Android 14 推出了 HardwareBufferRenderer
。如果您的用途涉及透過 SurfaceControl
與系統合成器通訊,以便繪製低延遲畫面,這個 API 就特別實用。