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 テストを実施したりできます。また、アプリがローカライズのためにサーバー側の push を使用する場合は、更新されたロケールのリストを提供できます。インプット メソッド エディタ(IME)によるアプリの言語の確認: IME は
getApplicationLocales()メソッドを使用して現在のアプリの言語を確認し、IME 言語をその言語と一致させます。
Grammatical Inflection API
3 billion people speak gendered languages: languages where grammatical categories—such as nouns, verbs, adjectives, and prepositions—inflect according to the gender of people and objects you talk to or about. Traditionally, many gendered languages use masculine grammatical gender as the default or generic gender.
Addressing users in the wrong grammatical gender, such as addressing women in masculine grammatical gender, can negatively impact their performance and attitude. In contrast, a UI with language that correctly reflects the user's grammatical gender can improve user engagement and provide a more personalized and natural-sounding user experience.
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.
地域の設定
用户可通过地区偏好设置对温度单位、一周的第一天和编号系统进行个性化设置。居住在美国的欧洲用户可能更希望使用摄氏度,而不是华氏度,并且希望应用将星期一视为一周的开始,而不是像美国那样默认从星期日开始。
新 Android 设置菜单包含这些偏好设置,使用户能够在一个位置集中发现这些应用更改偏好设置。这些偏好设置在备份和恢复设备后也会保持不变。多个 API 和 intent(例如 getTemperatureUnit 和 getFirstDayOfWeek)会为您的应用授予读取权限来访问用户偏好设置,因此您的应用可以调整其显示信息的方式。您还可以在 ACTION_LOCALE_CHANGED 上注册 BroadcastReceiver,以便在地区偏好设置发生更改时处理语言区域配置更改。
如需找到这些设置,请打开“设置”应用,然后依次前往系统 > 语言和输入法 > 地区偏好设置。
ユーザー補助
非線形フォント スケーリングを 200% にする
Android 14 以降では、フォント スケーリングが 200% までサポートされます。これにより、ユーザーは追加のユーザー補助オプションを利用できます。
画面上の大きいテキスト要素が拡大しすぎないように、システムでは非線形のスケーリング曲線が適用されます。このスケーリング戦略では、大きいテキストが小さいテキストとは異なる率でスケーリングされます。非線形フォント スケーリングにより、さまざまなサイズの要素間の比例階層を維持しながら、線形テキスト スケーリングの高度な問題(テキストが途切れる、表示サイズが大きすぎて文字が読みづらくなるなど)を軽減できます。
非線形フォント スケーリングでアプリをテストする
スケーラブル ピクセル(sp)単位をすでにテキストのサイズ設定に使用している場合は、これらの追加オプションとスケーリングの改善がアプリのテキストに自動的に適用されます。ただし、最大フォントサイズ(200%)を有効にして UI テストを実施し、アプリがフォントサイズを正しく適用し、ユーザビリティに影響を与えることなく大きなフォントサイズに対応できることを確認する必要があります。
200% のフォントサイズを有効にする手順は次のとおりです。
- 設定アプリを開き、[ユーザー補助] > [表示サイズとテキスト] に移動します。
- [フォントサイズ] オプションでは、最大フォントサイズの設定が有効になるまで、プラス(+)アイコンをタップします(このセクションに表示される画像で確認できます)。
テキストサイズにはスケール非依存ピクセル(sp)単位を使用する
テキストサイズは必ず sp 単位で指定してください。アプリで sp 単位を使用している場合、Android はユーザーが選択するテキストサイズを適用して適切にスケーリングできます。
パディングに sp 単位を使用したり、暗黙的なパディングを想定してビューの高さを定義したりしないでください。非線形フォント スケーリングでは sp のサイズが比例しない可能性があるため、4 sp + 20 sp = 24 sp にならない可能性があります。
スケール非依存ピクセル(sp)単位を変換する
sp 単位からピクセルに変換するには TypedValue.applyDimension() を、ピクセルを sp に変換するには TypedValue.deriveDimension() を使用します。これらのメソッドでは、適切な非線形スケーリング曲線が自動的に適用されます。
Configuration.fontScale または DisplayMetrics.scaledDensity を使用して方程式をハードコードしないでください。フォントのスケーリングが非線形になったため、scaledDensity フィールドは正確ではなくなっています。フォントは単一のスカラー値でスケーリングされなくなったため、fontScale フィールドは情報提供のみを目的として使用する必要があります。
lineHeight には sp 単位を使用する
android:lineHeight は、dp ではなく sp 単位を使用して常に定義してください。そうすることで、行の高さがテキストに合わせて拡大縮小されます。そうしないと、テキストが sp で lineHeight が dp または px の場合、スケーリングされず、窮屈に見えます。TextView は、意図した比率が維持されるように lineHeight を自動的に修正しますが、これは textSize と lineHeight の両方が sp 単位で定義されている場合に限られます。
カメラとメディア
画像のウルトラ HDR
Android 14 では、ハイ ダイナミック レンジ(HDR)画像のサポートが追加されました。HDR 画像では、写真の撮影時にセンサーからの情報の多くを保持できるため、鮮やかな色と高いコントラストを実現できます。Android では ウルトラ HDR 形式が使用されます。これは JPEG 画像と完全に下位互換性があるため、アプリは HDR 画像とシームレスに相互運用し、必要に応じて標準ダイナミック レンジ(SDR)で表示できます。
これらの画像を HDR で UI にレンダリングすることは、アプリがアクティビティ ウィンドウで HDR UI の使用をオプトインした場合、マニフェスト エントリを介して、または実行時に Window.setColorMode() を呼び出すことで、フレームワークによって自動的に実行されます。サポートされているデバイスでは、圧縮されたウルトラ HDR 静止画をキャプチャすることもできます。センサーから回復できる色が増えると、ポスト処理での編集がより柔軟になります。ウルトラ HDR 画像に関連付けられた Gainmap を使用して、OpenGL または Vulkan でレンダリングできます。
カメラ拡張機能のズーム、フォーカス、ポストビューなど
Android 14 では、カメラ拡張機能がアップグレードされ、改善されています。これにより、アプリはより長い処理時間を処理できるため、サポートされているデバイスで暗い場所での撮影などのコンピューティング負荷の高いアルゴリズムを使用して画像を改善できます。これらの機能により、カメラの拡張機能を使用する際のユーザー エクスペリエンスがさらに堅牢になります。主な改善点は次のとおりです。
- 動的な静止画撮影処理レイテンシの推定では、現在のシーンと環境条件に基づいて、はるかに正確な静止画撮影レイテンシの推定値が得られます。
CameraExtensionSession.getRealtimeStillCaptureLatency()を呼び出して、2 つのレイテンシ推定メソッドを持つStillCaptureLatencyオブジェクトを取得します。getCaptureLatency()メソッドは、onCaptureStartedとonCaptureProcessStarted()間の推定レイテンシを返します。getProcessingLatency()メソッドは、onCaptureProcessStarted()と利用可能な最終的な処理済みフレーム間の推定レイテンシを返します。 - キャプチャの進行状況コールバックをサポートし、アプリが長時間実行の静止画キャプチャ処理オペレーションの現在の進行状況を表示できるようにします。この機能が
CameraExtensionCharacteristics.isCaptureProcessProgressAvailableで使用可能かどうかを確認します。使用可能であれば、onCaptureProcessProgressed()コールバックを実装します。このコールバックには、進行状況(0 ~ 100)がパラメータとして渡されます。 拡張機能固有のメタデータ(
EXTENSION_BOKEHによる背景のぼかしの量など、拡張機能の効果の量を調整するためのCaptureRequest.EXTENSION_STRENGTHなど)。カメラ拡張機能の静止画撮影用ポストビュー機能。最終的な画像よりも処理が少ない画像をより迅速に提供します。拡張機能で処理レイテンシが増加している場合は、UX を改善するためにポストビュー画像をプレースホルダとして提供し、後で最終的な画像に切り替えることができます。この機能が使用可能かどうかは、
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 gains support for lossless audio formats for audiophile-level
experiences over USB wired headsets. You can query a USB device for its
preferred mixer attributes, register a listener for changes in preferred mixer
attributes, and configure mixer attributes using the
AudioMixerAttributes class. This class represents the
format, such as channel mask, sample rate, and behavior of the audio mixer. The
class allows for audio to be sent directly, without mixing,
volume adjustment, or processing effects.
デベロッパーの生産性とツール
認証情報マネージャー
Android 14 adds Credential Manager as a platform API, with additional support back to Android 4.4 (API level 19) devices through a Jetpack Library using Google Play services. Credential Manager aims to make sign-in easier for users with APIs that retrieve and store credentials with user-configured credential providers. Credential Manager supports multiple sign-in methods, including username and password, passkeys, and federated sign-in solutions (such as Sign-in with Google) in a single API.
Passkeys provide many advantages. For example, passkeys are built on industry standards, can work across different operating systems and browser ecosystems, and can be used with both websites and apps.
For more information, see the Credential Manager and passkeys documentation and the blogpost about Credential Manager and passkeys.
ヘルスコネクト
Health Connect 是用户健康与健身数据的设备端仓库。借助该功能,用户可以在一个位置控制要与这些应用共享哪些数据,并在自己喜爱的应用之间共享数据。
在搭载 Android 14 之前的 Android 版本的设备上,Health Connect 可作为应用从 Google Play 商店下载。从 Android 14 开始,Health Connect 将成为 Android 平台的一部分,并通过 Google Play 系统更新接收更新,而无需单独下载。这样一来,Health Connect 就可以频繁更新,您的应用可以依赖于搭载 Android 14 或更高版本的设备上提供的 Health Connect。用户可以通过设备的“设置”访问 Health Connect,隐私控制功能集成到系统设置中。
Health Connect 在 Android 14 中包含多项新功能,例如锻炼路线,可让用户分享可在地图上直观呈现的锻炼路线。路线定义为在一定时间范围内保存的位置列表,您的应用可以将路线插入锻炼时段,将它们关联起来。为确保用户能够完全控制此类敏感数据,用户必须允许与其他应用共享单个路线。
如需了解详情,请参阅 Health Connect 文档以及有关 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.baseclasses 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
instanceofwithout 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 がインストール セッションに書き込まれ、セッションが commit された後にのみ、アプリストアはユーザーの承認をリクエストできました。
Android 14 以降では、requestUserPreapproval() メソッドを使用して、インストール セッションを commit する前に、ユーザーの承認をリクエストできます。この改善により、ユーザーがインストールを承認するまで、アプリストアで APK のダウンロードが延期されます。さらに、ユーザーがインストールを承認すると、アプリストアはユーザーの作業を妨げることなく、バックグラウンドでアプリをダウンロードしてインストールできます。
今後の更新に責任を持つことを示す
setRequestUpdateOwnership() メソッドを使用すると、インストーラはインストールしているアプリの今後の更新に責任を持つことをシステムに示すことができます。この機能により、更新の所有権の適用が有効になります。つまり、更新の所有者のみがアプリに自動更新をインストールできます。更新の所有権を適用することで、ユーザーは想定されるアプリストアからのみ更新を受け取ることができます。
その他のインストーラ(INSTALL_PACKAGES 権限を利用するものを含む)は、更新をインストールするために、ユーザーの明示的な承認を得る必要があります。ユーザーが別のソースから更新を進めた場合、更新の所有権は失われます。
影響が少ないタイミングでアプリを更新する
アプリストアは通常、アクティブに使用されているアプリを更新することはありません。これは、アプリの実行中のプロセスが強制終了され、ユーザーの操作が中断される可能性があるためです。
Android 14 以降では、InstallConstraints API を使用することで、インストーラはアプリの更新を適切なタイミングで行えます。たとえば、アプリストアで commitSessionAfterInstallConstraintsAreMet() メソッドを呼び出して、ユーザーがそのアプリを操作しなくなったときにのみ更新が commit されるようにできます。
オプションの分割をシームレスにインストールする
分割 APK を使用すると、アプリの機能をモノリシック APK としてではなく、別々の APK ファイルで配信できます。これにより、アプリストアでさまざまなアプリ コンポーネントの配信を最適化できます。たとえば、アプリストアは、ターゲット デバイスのプロパティに基づいて最適化できます。PackageInstaller API は、API レベル 22 で導入されて以来、分割をサポートしています。
Android 14 では、setDontKillApp() メソッドを使用して、新しい分割がインストールされたときに、アプリの実行中のプロセスを強制終了すべきでないことを示せます。アプリストアでは、この機能を使用して、ユーザーがアプリを使用しているときに、アプリの新しい機能をシームレスにインストールできます。
アプリのメタデータ バンドル
Starting in Android 14, the Android package installer lets you specify app metadata, such as data safety practices, to include on app store pages such as 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.
ユーザー エクスペリエンス
共有シートのカスタム アクションとランキングの改善
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 の「ホームに戻る」アニメーションに伴い、新しいシステム アニメーションが追加されました。新しいシステム アニメーションはアクティビティ間およびタスク間で動作し、予測型「戻る」に移行すると自動的に適用されます。
- ボトムシート、サイドシート、検索に新しいマテリアル コンポーネント アニメーションを追加しました。
- カスタムのアプリ内アニメーションと遷移を作成する際の設計ガイダンスを作成しました。
- カスタムのアプリ内遷移アニメーションをサポートする新しい API が追加されました。
handleOnBackStarted、handleOnBackProgressed、handleOnBackCancelledinOnBackPressedCallbackonBackStarted、onBackProgressed、onBackCancelledinOnBackAnimationCallback- ユーザーが後方にスワイプしたときに遷移を再生するには、
overridePendingTransitionではなくoverrideActivityTransitionを使用します。
この Android 14 プレビュー リリースでは、予測型「戻る」のすべての機能は開発者向けオプションに引き続き隠されています。アプリを予測型「戻る」に移行するデベロッパー ガイドと、カスタム アプリ内遷移を作成するデベロッパー ガイドをご覧ください。
大画面デバイスのメーカーによるアプリごとのオーバーライド
Per-app overrides enable device manufacturers to change the behavior of apps on large screen devices. For example, the FORCE_RESIZE_APP override instructs the system to resize the app to fit display dimensions (avoiding size compatibility mode) even if resizeableActivity="false" is set in the app manifest.
Overrides are intended to improve the user experience on large screens.
New manifest properties enable you to disable some device manufacturer overrides for your app.
大画面ユーザーのアプリごとのオーバーライド
Per-app overrides change the behavior of apps on large screen devices. For example, the OVERRIDE_MIN_ASPECT_RATIO_LARGE device manufacturer override sets the app aspect ratio to 16:9 regardless of the app's configuration.
Android 14 QPR1 enables users to apply per‑app overrides by means of a new settings menu on large screen devices.
アプリの画面共有
App screen sharing enables users to share an app window instead of the entire device screen during screen content recording.
With app screen sharing, the status bar, navigation bar, notifications, and other system UI elements are excluded from the shared display. Only the content of the selected app is shared.
App screen sharing improves productivity and privacy by enabling users to run multiple apps but limit content sharing to a single app.
Google Pixel 8 Pro の Gboard で LLM を活用したスマート リプライを使用する
12 月の機能ドロップが適用された Google Pixel 8 Pro デバイスでは、Google Tensor で実行されるオンデバイスの大規模言語モデル(LLM)を活用した、Gboard の品質の高いスマート リプライをデベロッパーが試すことができます。
この機能は、WhatsApp、Line、KakaoTalk で米国英語の限定プレビューとしてご利用いただけます。Google Pixel 8 Pro デバイスを Gboard をキーボードとして使用する必要があります。
試すには、まず [設定] > [開発者向けオプション] > [AICore の設定] > [Aicore Persistent を有効にする] でこの機能を有効にします。
次に、対応するアプリで会話を開くと、受信したメッセージに応じて Gboard の候補ストリップに LLM を活用したスマート リプライが表示されます。
グラフィック
パスのクエリと補間に対応
Android's Path API is a powerful and flexible mechanism for
creating and rendering vector graphics, with the ability to stroke or fill a
path, construct a path from line segments or quadratic or cubic curves, perform
boolean operations to get even more complex shapes, or all of these
simultaneously. One limitation is the ability to find out what is actually in a
Path object; the internals of the object are opaque to callers after creation.
To create a Path, you call methods such as
moveTo(), lineTo(), and
cubicTo() to add path segments. But there has been no way to
ask that path what the segments are, so you must retain that information at
creation time.
Starting in Android 14, you can query paths to find out what's inside of them.
First, you need to get a PathIterator object using the
Path.getPathIterator API:
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();
Next, you can call PathIterator to iterate through the segments
one by one, retrieving all of the necessary data for each segment. This example
uses PathIterator.Segment objects, which packages up the data
for you:
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 also has a non-allocating version of next() where you can pass
in a buffer to hold the point data.
One of the important use cases of querying Path data is interpolation. For
example, you might want to animate (or morph) between two different paths. To
further simplify that use case, Android 14 also includes the
interpolate() method on Path. Assuming the two paths have
the same internal structure, the interpolate() method creates a new Path
with that interpolated result. This example returns a path whose shape is
halfway (a linear interpolation of .5) between path and otherPath:
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); }
The Jetpack graphics-path library enables similar APIs for earlier versions of Android as well.
頂点シェーダーとフラグメント シェーダーを使用したカスタム メッシュ
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 のハードウェア バッファ レンダラ
To assist in using Android's Canvas API to draw with
hardware acceleration into a HardwareBuffer, Android 14
introduces HardwareBufferRenderer. This API is
particularly useful when your use case involves communication with the system
compositor through SurfaceControl for low-latency
drawing.