기능 및 API 개요

Android 14에는 개발자를 위한 훌륭한 기능과 API가 도입되었습니다. 다음을 통해 앱의 기능을 알아보고 관련 API를 시작할 수 있습니다.

추가된 API, 수정된 API, 삭제된 API에 관한 자세한 목록은 API 차이점 보고서를 참고하세요. 추가된 API에 관한 자세한 내용은 Android API 참조를 참고하세요. Android 14의 경우 API 수준 34에 추가된 API를 찾아보세요. 플랫폼 변경이 앱에 영향을 줄 수 있는 분야에 관해 알아보려면 Android 14를 타겟팅하는 앱모든 앱의 Android 14 동작 변경사항을 확인하세요.

다국어 지원

앱별 언어 설정

Android 14 expands on the per-app language features that were introduced in Android 13 (API level 33) with these additional capabilities:

  • Automatically generate an app's localeConfig: Starting with Android Studio Giraffe Canary 7 and AGP 8.1.0-alpha07, you can configure your app to support per-app language preferences automatically. Based on your project resources, the Android Gradle plugin generates the LocaleConfig file and adds a reference to it in the final manifest file, so you no longer have to create or update the file manually. AGP uses the resources in the res folders of your app modules and any library module dependencies to determine the locales to include in the LocaleConfig file.

  • Dynamic updates for an app's localeConfig: Use the setOverrideLocaleConfig() and getOverrideLocaleConfig() methods in LocaleManager to dynamically update your app's list of supported languages in the device's system settings. Use this flexibility to customize the list of supported languages per region, run A/B experiments, or provide an updated list of locales if your app utilizes server-side pushes for localization.

  • App language visibility for input method editors (IMEs): IMEs can utilize the getApplicationLocales() method to check the language of the current app and match the IME language to that language.

Grammatical Inflection API

有 30 亿人在使用区分性别的语言,此类语言的语法类别(例如名词、动词、形容词和介词)会根据您交谈所涉及的人或物的性别而变化。传统上,许多区分性别的语言使用阳性语法性别作为默认或通用性别。

以错误的语法性别来称呼用户,例如以阳性语法性别来称呼女性,可能会对她们的表现和态度产生负面影响。相比之下,界面语言如果能正确反映用户的语法性别,就可以提高用户互动度,并提供更个性化、更自然的用户体验。

To help you build a user-centric UI for gendered languages, Android 14 introduces the Grammatical Inflection API, which lets you add support for grammatical gender without refactoring your app.

지역 설정

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.

Regional preferences screen in Android system settings.
Temperature options for regional preferences in Android system settings.

접근성

비선형 글꼴 크기 200%로 조정

从 Android 14 开始,系统支持字体放大高达 200%,为弱视用户提供了符合网络内容无障碍指南 (WCAG) 的其他无障碍选项。

为防止屏幕上的大文本元素放大过大,系统会采用非线性放大曲线。这种放大策略意味着大号文本的放大比例不会与较小的文本相同。非线性字体缩放有助于保持不同大小元素之间的比例层次结构,同时缓解高级别线性文本缩放的问题(例如文本被截断或文本因超大显示大小而难以阅读)。

使用非线性字体放大测试应用

在设备的无障碍设置中启用最大字号,以测试应用。

如果您已经使用放大像素 (sp) 单位来定义文本大小,那么这些额外的选项和缩放改进会自动应用于应用中的文本。但是,您仍然应该在启用最大字体大小 (200%) 的情况下执行界面测试,以确保应用正确应用字体大小,并且可以适应更大的字体大小,而不影响易用性。

要启用 200% 字号,请按以下步骤操作:

  1. 打开“设置”应用,然后依次前往无障碍 > 显示大小和文字
  2. 字号选项中,点按加号 (+) 图标,直到启用最大字号设置,如本部分随附的图片所示。

针对文本大小使用放大像素 (sp) 单位

请务必始终以 sp 为单位指定文本大小。当应用使用 sp 单位时,Android 可以应用用户的首选文本大小并相应地缩放。

不要为内边距使用 sp 单位,也不假设隐式内边距定义视图高度:使用非线性字体缩放 sp 尺寸可能不成比例,因此 4sp + 20sp 可能不等于 24sp。

转换放大像素 (sp) 单位

使用 TypedValue.applyDimension() 从 sp 单位转换为像素,并使用 TypedValue.deriveDimension() 将像素转换为 sp。这些方法会自动应用适当的非线性缩放曲线。

避免使用 Configuration.fontScaleDisplayMetrics.scaledDensity 对方程进行硬编码。由于字体缩放是非线性的,因此 scaledDensity 字段不再准确。fontScale 字段应仅用于提供信息,因为字体不再使用单个标量值进行缩放。

对 lineHeight 使用 sp 单位

始终使用 sp 单位(而非 dp)定义 android:lineHeight,以便行高随文本一起缩放。否则,如果您的文本为 sp,而 lineHeight 以 dp 或 px 为单位,则文本无法缩放且看起来狭窄。TextView 会自动更正 lineHeight 以保留您预期的比例,但前提是以 sp 为单位同时定义 textSizelineHeight

카메라 및 미디어

이미지용 울트라 HDR

An illustration of Standard Dynamic Range (SDR) versus High Dynamic Range (HDR) image quality.

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 upgrades and improves camera extensions, allowing apps to handle longer processing times, which enables improved images using compute-intensive algorithms like low-light photography on supported devices. These features give users an even more robust experience when using camera extension capabilities. Examples of these improvements include:

센서 내 줌

CameraCharacteristics 中的 REQUEST_AVAILABLE_CAPABILITIES_STREAM_USE_CASE 包含 SCALER_AVAILABLE_STREAM_USE_CASES_CROPPED_RAW 时,您的应用可以使用高级传感器功能,将剪裁后的 RAW 数据流的像素与全视野范围相同,方法是将 CaptureRequest 与将数据流用例设置为 CameraMetadata.SCALER_AVAILABLE_STREAM_USE_CASES_CROPPED_RAW 的 RAW 目标搭配使用。通过实现请求替换控件,更新后的相机可让用户在其他相机控件准备就绪之前使用缩放控件。

무손실 USB 오디오

Android 14에서는 USB 유선 헤드셋을 통한 오디오필 수준의 환경을 위한 무손실 오디오 형식을 지원합니다. USB 기기에서 기본 믹서 속성을 쿼리하고, 기본 믹서 속성 변경에 관한 리스너를 등록하고, AudioMixerAttributes 클래스를 사용하여 믹서 속성을 구성할 수 있습니다. 이 클래스는 채널 마스크, 샘플링 레이트, 오디오 믹서의 동작과 같은 형식을 나타냅니다. 이 클래스를 사용하면 믹싱, 볼륨 조정 또는 효과 처리 없이 오디오를 직접 전송할 수 있습니다.

개발자 생산성 및 도구

인증 관리자

Android 14 将 Credential Manager 添加为平台 API,并通过使用 Google Play 服务的 Jetpack 库,向后额外支持 Android 4.4(API 级别 19)设备。Credential Manager 旨在通过 API 使用用户配置的凭据提供程序检索和存储凭据,让用户更轻松地登录。Credential Manager 在单个 API 中支持多种登录方法,包括用户名和密码、通行密钥和联合登录解决方案(如“使用 Google 账号登录”)。

通行密钥具有许多优势。例如,通行密钥是基于业界标准构建的,可在各种不同的操作系统和浏览器生态系统中使用,并且可用于网站和应用。

如需了解详情,请参阅 Credential Manager 和通行密钥文档以及介绍 Credential Manager 和通行密钥的博文

헬스 커넥트

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.

Users can get started using Health Connect without a separate app download on devices running Android 14 or higher.
Users can control which apps have access to their health and fitness data through 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에서는 앱 및 플랫폼 개발자를 위한 라이브러리 업데이트와 Java 17 언어 지원을 비롯하여 최신 OpenJDK LTS 출시의 기능과 일치하도록 Android의 핵심 라이브러리를 새로고침하는 작업을 계속하고 있습니다.

다음과 같은 기능과 개선사항이 포함됩니다.

  • Java 17을 지원하도록 약 300개의 java.base 클래스를 업데이트했습니다.
  • 텍스트 블록: Java 프로그래밍 언어에 여러 줄의 문자열 리터럴을 도입합니다.
  • instanceof의 패턴 일치: 추가 변수 없이 객체를 instanceof에 특정 유형이 있는 것으로 취급할 수 있습니다.
  • 봉인 클래스: 이를 확장하거나 구현할 수 있는 클래스와 인터페이스를 제한할 수 있습니다.

Google Play 시스템 업데이트(Project Mainline) 덕분에 6억 개가 넘는 기기에서 이러한 변경사항이 포함된 최신 Android 런타임(ART) 업데이트를 받을 수 있습니다. 이는 여러 기기에서 앱에 보다 일관되고 안전한 환경을 제공하고 플랫폼 출시와 관계없이 사용자에게 새로운 기능을 제공하기 위한 노력의 일환입니다.

Java 및 OpenJDK는 Oracle 및/또는 그 계열사의 상표 또는 등록 상표입니다.

앱 스토어 개선사항

Android 14 引入了多个 PackageInstaller API,可帮助应用商店改善其用户体验。

下载之前请求批准安装

安装或更新应用可能需要用户批准。例如,当使用 REQUEST_INSTALL_PACKAGES 权限的安装程序尝试安装新应用时。在之前的 Android 版本中,只有在将 APK 写入安装会话并且提交会话后,应用商店才能请求用户批准。

从 Android 14 开始,requestUserPreapproval() 方法可让安装程序在提交安装会话之前请求用户批准。此项改进可让应用商店将任何 APK 的下载操作推迟到用户批准安装之后。此外,用户批准安装后,应用商店可以在后台下载并安装应用,而不会干扰用户。

承担未来更新的责任

借助 setRequestUpdateOwnership() 方法,安装程序可以向系统表明它打算负责将被安装的应用未来的更新。此 capability 可实现更新所有权强制执行,即仅允许更新所有者为应用安装自动更新。更新所有权强制执行有助于确保用户仅收到来自预期应用商店的更新。

任何其他安装程序(包括使用 INSTALL_PACKAGES 权限的安装程序)都必须获得用户的明确批准,才能安装更新。如果用户决定继续从其他来源安装更新,则会失去更新所有权。

在干扰较少的时段更新应用

应用商店通常希望避免更新正在使用的应用,因为这会导致应用正在运行的进程被终止,而这可能会中断用户正在执行的操作。

从 Android 14 开始,InstallConstraints API 让安装程序可以确保其应用更新在适当的时机进行。例如,应用商店可以调用 commitSessionAfterInstallConstraintsAreMet() 方法来确保仅在用户不再与相应应用互动时才进行更新。

无缝安装可选拆分

借助拆分 APK,应用的功能可以通过单独的 APK 文件提供,而不是以单体式 APK 的形式提供。借助拆分 APK,应用商店可以优化不同应用组件的提供。例如,应用商店可能会根据目标设备的属性进行优化。自在 API 级别 22 中引入以来,PackageInstaller API 一直支持拆分。

在 Android 14 中,setDontKillApp() 方法可让安装程序指明在安装新的拆分项时应用的运行进程不应终止。应用商店可以使用此功能,在用户使用应用时无缝安装应用的新功能。

앱 메타데이터 번들

从 Android 14 开始,Android 软件包安装程序可让您指定应用元数据(例如数据安全做法),以在 Google Play 等应用商店页面上架。

사용자가 기기 스크린샷을 찍을 때 감지

为了打造更加标准化的屏幕截图检测体验,Android 14 引入了可保护隐私的屏幕截图检测 API。借助此 API,应用可以按 activity 注册回调。如果用户在该 activity 可见时截取屏幕截图,系统会调用这些回调并通知用户。

사용자 환경

Sharesheet 맞춤 작업 및 개선된 순위 지정

Android 14에서는 맞춤 앱 작업과 사용자에게 더 많은 정보를 제공하는 미리보기 결과를 지원하도록 시스템 Sharesheet를 업데이트합니다.

맞춤 작업 추가

Android 14에서는 앱에서 호출하는 시스템 Sharesheet에 맞춤 작업을 추가할 수 있습니다.

Sharesheet의 맞춤 작업 스크린샷

직접 공유 타겟의 순위 향상

Android 14는 앱에서 더 많은 신호를 사용하여 직접 공유 타겟의 순위를 결정하고 사용자에게 더 유용한 결과를 제공합니다. 순위에 가장 유용한 신호를 제공하려면 직접 공유 타겟의 순위 향상에 관한 안내를 따르세요. 커뮤니케이션 앱은 발신 및 수신 메시지의 단축키 사용을 보고할 수도 있습니다.

Sharesheet의 직접 공유 행(1 참고)

뒤로 탐색 예측을 위한 내장 및 맞춤 애니메이션 지원

视频:预测性返回动画

Android 13 在开发者选项背后引入了预测性“返回主屏幕”动画。在已启用开发者选项的受支持应用中使用时,滑回手势会显示动画,表明返回手势会使应用退回到主屏幕。

Android 14 包含针对“预测性返回”的多项改进和新指南:

在此 Android 14 预览版中,所有预测性返回功能都是位于开发者选项背后。请参阅与将您的应用迁移到预测性返回有关的开发者指南,以及与创建自定义应用内转换有关的开发者指南

대형 화면 기기 제조업체의 앱별 재정의

앱별 재정의를 사용하면 기기 제조업체가 대형 화면 기기에서 앱의 동작을 변경할 수 있습니다. 예를 들어 FORCE_RESIZE_APP 재정의는 앱 매니페스트에 resizeableActivity="false"가 설정되어 있더라도 디스플레이 크기에 맞게 앱의 크기를 조절하도록 시스템에 지시합니다 (크기 호환성 모드 피하기).

재정의는 대형 화면에서 사용자 환경을 개선하기 위한 것입니다.

새 매니페스트 속성을 사용하면 앱에 대한 일부 기기 제조업체 재정의를 사용 중지할 수 있습니다.

대형 화면 사용자 앱별 재정의

按应用替换项会更改应用在大屏设备上的行为。例如,无论应用的配置如何,OVERRIDE_MIN_ASPECT_RATIO_LARGE 设备制造商替换项都会将应用宽高比设置为 16:9。

借助 Android 14 QPR1,用户可以在大屏设备上通过新的设置菜单应用按应用替换项。

앱 화면 공유

借助应用界面共享功能,用户可以在录制屏幕内容时共享应用窗口,而不是整个设备屏幕。

在应用屏幕共享模式下,状态栏、导航栏、通知和其他系统界面元素会从共享显示屏中排除。系统只会分享所选应用的内容。

应用屏幕共享功能可让用户运行多个应用,但将内容共享限制为单个应用,从而提高工作效率并保护隐私。

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.

Gboard utilizes on-device LLMs to provide higher-quality smart replies.

그래픽

경로를 쿼리하고 보간할 수 있음

Android 的 Path API 是一种强大且灵活的机制,可用于创建和渲染矢量图形,能够描边或填充路径、根据线段或二次曲线或立方曲线构建路径、执行布尔运算以获取更复杂的形状,或同时执行所有这些操作。但有一个限制是,您无法了解 Path 对象中实际包含的内容;该对象的内部信息在创建后对调用方是不透明的。

如需创建 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。以下示例返回了一个形状介于 pathotherPath 之间的一半(线性插值为 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.

캔버스의 하드웨어 버퍼 렌더러

Android의 Canvas API를 사용하여 하드웨어 가속으로 HardwareBuffer에 그리는 것을 지원하기 위해 Android 14에서는 HardwareBufferRenderer를 도입합니다. 이 API는 시스템과의 통신이 포함된 사용 사례에 특히 유용합니다 짧은 지연 시간을 위해 SurfaceControl를 통한 컴포지터 있습니다.