動作の変更点: Android 15 以上をターゲットとするアプリ

以前のリリースと同様に、Android 15 には、アプリに影響を与える可能性のある動作変更が含まれています。下記の動作変更は、Android 15 以上をターゲットとするアプリに限り適用されます。アプリが Android 15 以上をターゲットとする場合は、必要に応じてアプリを変更し、下記の動作に適切に対応できるようにしてください。

アプリの targetSdkVersion に関係なく、Android 15 で実行されるすべてのアプリに影響する動作変更のリストも必ずご確認ください。

コア機能

Android 15 では、Android システムのさまざまなコア機能を変更または拡張しています。

フォアグラウンド サービスの変更

我们将对 Android 15 中的前台服务进行以下更改。

数据同步前台服务超时行为

Android 15 では、Android 15(API レベル 35)以降をターゲットとするアプリに対して、dataSync に新しいタイムアウト動作が導入されます。この動作は、新しい mediaProcessing フォアグラウンド サービス タイプにも適用されます。

システムは、アプリの dataSync サービスを 24 時間以内に合計 6 時間実行することを許可します。その後、システムは実行中のサービスの Service.onTimeout(int, int) メソッド(Android 15 で導入)を呼び出します。この時点で、サービスは Service.stopSelf() を呼び出すために数秒間待機します。Service.onTimeout() が呼び出されると、サービスはフォアグラウンド サービスと見なされなくなります。サービスが Service.stopSelf() を呼び出さない場合、システムは内部例外をスローします。例外が Logcat に次のメッセージとともに記録されます。

Fatal Exception: android.app.RemoteServiceException: "A foreground service of
type dataSync did not stop within its timeout: [component name]"

この動作変更の問題を回避するには、次のいずれかを行います。

  1. サービスに新しい Service.onTimeout(int, int) メソッドを実装します。アプリがコールバックを受信したら、数秒以内に stopSelf() を呼び出します。(アプリをすぐに停止しないと、システムは障害を生成します)。
  2. アプリの dataSync サービスが 24 時間以内に合計 6 時間を超えて実行されないようにしてください(ユーザーがアプリを操作してタイマーをリセットする場合を除きます)。
  3. dataSync フォアグラウンド サービスは、直接のユーザー操作の結果としてのみ起動します。サービスの開始時にアプリはフォアグラウンドにあるため、サービスはバックグラウンドに移行してから 6 時間すべてかかります。
  4. dataSync フォアグラウンド サービスではなく、代替 API を使用してください。

アプリの dataSync フォアグラウンド サービスが過去 24 時間以内に 6 時間実行されている場合、ユーザーがアプリをフォアグラウンドに表示した(これによりタイマーがリセットされる)場合を除き、別の dataSync フォアグラウンド サービスを開始することはできません。別の dataSync フォアグラウンド サービスを開始しようとすると、システムは ForegroundServiceStartNotAllowedException をスローし、「フォアグラウンド サービス タイプ dataSync の制限時間はすでに経過しています」などのエラー メッセージを出力します。

テスト

アプリの動作をテストするには、アプリが Android 15 をターゲットとしていない場合でも、データ同期のタイムアウトを有効にできます(アプリが Android 15 デバイスで実行されている場合)。タイムアウトを有効にするには、次の adb コマンドを実行します。

adb shell am compat enable FGS_INTRODUCE_TIME_LIMITS your-package-name

タイムアウト期間を調整して、上限に達したときアプリの動作を簡単にテストすることもできます。新しいタイムアウト期間を設定するには、次の adb コマンドを実行します。

adb shell device_config put activity_manager data_sync_fgs_timeout_duration duration-in-milliseconds

新的媒体处理前台服务类型

Android 15 introduces a new foreground service type, mediaProcessing. This service type is appropriate for operations like transcoding media files. For example, a media app might download an audio file and need to convert it to a different format before playing it. You can use a mediaProcessing foreground service to make sure the conversion continues even while the app is in the background.

The system permits an app's mediaProcessing services to run for a total of 6 hours in a 24-hour period, after which the system calls the running service's Service.onTimeout(int, int) method (introduced in Android 15). At this time, the service has a few seconds to call Service.stopSelf(). If the service does not call Service.stopSelf(), the system throws an internal exception. The exception is logged in Logcat with the following message:

Fatal Exception: android.app.RemoteServiceException: "A foreground service of
type mediaProcessing did not stop within its timeout: [component name]"

To avoid having the exception, you can do one of the following:

  1. Have your service implement the new Service.onTimeout(int, int) method. When your app receives the callback, make sure to call stopSelf() within a few seconds. (If you don't stop the app right away, the system generates a failure.)
  2. Make sure your app's mediaProcessing services don't run for more than a total of 6 hours in any 24-hour period (unless the user interacts with the app, resetting the timer).
  3. Only start mediaProcessing foreground services as a result of direct user interaction; since your app is in the foreground when the service starts, your service has the full six hours after the app goes to the background.
  4. Instead of using a mediaProcessing foreground service, use an alternative API, like WorkManager.

If your app's mediaProcessing foreground services have run for 6 hours in the last 24, you cannot start another mediaProcessing foreground service unless the user has brought your app to the foreground (which resets the timer). If you try to start another mediaProcessing foreground service, the system throws ForegroundServiceStartNotAllowedException with an error message like "Time limit already exhausted for foreground service type mediaProcessing".

For more information about the mediaProcessing service type, see Changes to foreground service types for Android 15: Media processing.

Testing

To test your app's behavior, you can enable media processing timeouts even if your app is not targeting Android 15 (as long as the app is running on an Android 15 device). To enable timeouts, run the following adb command:

adb shell am compat enable FGS_INTRODUCE_TIME_LIMITS your-package-name

You can also adjust the timeout period, to make it easier to test how your app behaves when the limit is reached. To set a new timeout period, run the following adb command:

adb shell device_config put activity_manager media_processing_fgs_timeout_duration duration-in-milliseconds

对启动前台服务的 BOOT_COMPLETED 广播接收器的限制

BOOT_COMPLETED ブロードキャスト レシーバに対する新しい制限事項がリリースされます フォアグラウンド サービスの場合。BOOT_COMPLETED レシーバーは、API 呼び出しを起動できない フォアグラウンド サービスのタイプを使用できます。

BOOT_COMPLETED レシーバーがこれらのタイプのフォアグラウンドのいずれかを起動しようとした場合 サービスの場合、システムは ForegroundServiceStartNotAllowedException をスローします。

テスト

アプリの動作をテストするには、アプリが Android 15 をターゲットとしていない場合でも、これらの新しい制限を有効にできます(アプリが Android 15 デバイスで実行されている場合)。次の adb コマンドを実行します。

adb shell am compat enable FGS_BOOT_COMPLETED_RESTRICTIONS your-package-name

デバイスを再起動せずに BOOT_COMPLETED ブロードキャストを送信するには、次の操作を行います。 次の adb コマンドを実行します。

adb shell am broadcast -a android.intent.action.BOOT_COMPLETED your-package-name

在应用拥有 SYSTEM_ALERT_WINDOW 权限时启动前台服务的限制

以前,如果应用拥有 SYSTEM_ALERT_WINDOW 权限,即使应用当前在后台运行,也可以启动前台服务(如免于后台启动限制中所述)。

如果应用以 Android 15 为目标平台,则此豁免范围现在更窄。现在,应用需要具有 SYSTEM_ALERT_WINDOW 权限,并且需要有一个可见的叠加窗口。也就是说,应用需要先启动 TYPE_APPLICATION_OVERLAY 窗口,并且该窗口需要处于可见状态,然后您才能启动前台服务。

如果您的应用尝试从后台启动前台服务,但不符合这些新要求(并且没有其他豁免情况),系统会抛出 ForegroundServiceStartNotAllowedException

如果您的应用声明了 SYSTEM_ALERT_WINDOW 权限并从后台启动前台服务,则可能会受到此变更的影响。如果您的应用获得了 ForegroundServiceStartNotAllowedException,请检查应用的操作顺序,并确保应用在尝试从后台启动前台服务之前已具有有效的叠加层窗口。您可以通过调用 View.getWindowVisibility() 检查叠加层窗口当前是否可见,也可以替换 View.onWindowVisibilityChanged(),以便在可见性发生变化时收到通知。

测试

如需测试应用的行为,您可以启用这些新限制,即使您的应用并未以 Android 15 为目标平台(只要应用在 Android 15 设备上运行)也是如此。如需针对从后台启动前台服务启用这些新限制,请运行以下 adb 命令:

adb shell am compat enable FGS_SAW_RESTRICTIONS your-package-name

アプリがサイレント モードのグローバル状態を変更できるタイミングの変更

Android 15(API レベル 35)以降をターゲットとするアプリは、デバイスのサイレント(DND)モードのグローバル状態やポリシーを変更できなくなりました(ユーザー設定の変更や DND モードのオフによる変更も含みます)。代わりに、アプリは AutomaticZenRule を提供する必要がある。システムは、既存の最も制限の厳しいポリシーが優先されるスキームで、これをグローバル ポリシーに統合します。以前はグローバル状態に影響していた既存の API(setInterruptionFiltersetNotificationPolicy)を呼び出すと、暗黙的な AutomaticZenRule が作成または更新されます。この AutomaticZenRule は、API 呼び出しの呼び出しサイクルに応じてオンまたはオフに切り替わります。

この変更は、アプリが setInterruptionFilter(INTERRUPTION_FILTER_ALL) を呼び出し、その呼び出しによって所有者によって以前に有効にされた AutomaticZenRule が無効になることを想定している場合にのみ、検出可能な動作に影響します。

OpenJDK API の変更

Android 15 では、最新の OpenJDK LTS リリースの機能に合わせて Android のコアライブラリを更新する取り組みが引き続き行われています。

これらの変更のいくつかは、Android 15(API レベル 35)をターゲットとするアプリの互換性に影響する可能性があります。

  • String Formatting API の変更: 次の String.format() API と Formatter.format() API を使用する場合、引数の索引、フラグ、幅、精度の検証が厳格になりました。

    たとえば、引数インデックスが 0 の場合(形式文字列の %0)、次の例外がスローされます。

    IllegalFormatArgumentIndexException: Illegal format argument index = 0
    

    この場合は、引数インデックス 1(形式文字列の %1)を使用して問題を解決できます。

  • Arrays.asList(...).toArray() のコンポーネント タイプの変更: Arrays.asList(...).toArray() を使用する場合、結果のアレイのコンポーネント タイプは、基になる配列の要素の型ではなく、Object になりました。したがって、次のコードは ClassCastException をスローします。

    String[] elements = (String[]) Arrays.asList("one", "two").toArray();
    

    この場合、結果のアレイでコンポーネント タイプとして String を保持するには、代わりに Collection.toArray(Object[]) を使用します。

    String[] elements = Arrays.asList("two", "one").toArray(new String[0]);
    
  • 言語コードの処理の変更: Locale API を使用する場合、ヘブライ語、イディッシュ語、インドネシア語の言語コードは、廃止された形式(ヘブライ語: iw、イディッシュ語: ji、インドネシア語: in)に変換されなくなりました。これらの言語 / 地域の言語コードを指定する場合は、代わりに ISO 639-1 のコード(ヘブライ語: he、イディッシュ語: yi、インドネシア語: id)を使用してください。

  • 乱数 int シーケンスの変更: https://bugs.openjdk.org/browse/JDK-8301574 で行われた変更により、次の Random.ints() メソッドは Random.nextInt() メソッドとは異なる数列を返すようになりました。

    通常、この変更によってアプリの動作に異常が生じることはありませんが、コードで Random.ints() メソッドから生成されたシーケンスが Random.nextInt() と一致することを想定しないでください。

新しい SequencedCollection API は、アプリのビルド構成で compileSdk を更新して Android 15(API レベル 35)を使用するようにした後、アプリの互換性に影響する可能性があります。

  • kotlin-stdlibMutableList.removeFirst() 拡張関数と MutableList.removeLast() 拡張関数との競合

    Java の List 型は、Kotlin の MutableList 型にマッピングされます。List.removeFirst() API と List.removeLast() API は Android 15(API レベル 35)で導入されたため、Kotlin コンパイラは、list.removeFirst() などの関数呼び出しを、kotlin-stdlib の拡張関数ではなく、新しい List API に静的に解決します。

    compileSdk35 に設定され、minSdk34 以下に設定された状態でアプリが再コンパイルされ、Android 14 以前でアプリが実行されると、ランタイム エラーがスローされます。

    java.lang.NoSuchMethodError: No virtual method
    removeFirst()Ljava/lang/Object; in class Ljava/util/ArrayList;
    

    Android Gradle プラグインの既存の NewApi lint オプションは、これらの新しい API の使用を検出できます。

    ./gradlew lint
    
    MainActivity.kt:41: Error: Call requires API level 35 (current min is 34): java.util.List#removeFirst [NewApi]
          list.removeFirst()
    

    ランタイム例外と lint エラーを修正するには、Kotlin で removeFirst() 関数呼び出しと removeLast() 関数呼び出しをそれぞれ removeAt(0)removeAt(list.lastIndex) に置き換えます。Android Studio Ladybug | 2024.1.3 以降を使用している場合は、これらのエラーの簡単な修正オプションも用意されています。

    lint オプションが無効になっている場合は、@SuppressLint("NewApi")lintOptions { disable 'NewApi' } の削除を検討してください。

  • Java の他のメソッドとの競合

    既存のタイプに新しいメソッドが追加されました(ListDeque など)。これらの新しいメソッドは、他のインターフェースやクラスの同じ名前と引数型のメソッドと互換性がない場合があります。メソッド シグネチャの競合と非互換性がある場合、javac コンパイラはビルド時エラーを出力します。次に例を示します。

    エラーの例 1:

    javac MyList.java
    
    MyList.java:135: error: removeLast() in MyList cannot implement removeLast() in List
      public void removeLast() {
                  ^
      return type void is not compatible with Object
      where E is a type-variable:
        E extends Object declared in interface List
    

    エラーの例 2:

    javac MyList.java
    
    MyList.java:7: error: types Deque<Object> and List<Object> are incompatible;
    public class MyList implements  List<Object>, Deque<Object> {
      both define reversed(), but with unrelated return types
    1 error
    

    エラーの例 3:

    javac MyList.java
    
    MyList.java:43: error: types List<E#1> and MyInterface<E#2> are incompatible;
    public static class MyList implements List<Object>, MyInterface<Object> {
      class MyList inherits unrelated defaults for getFirst() from types List and MyInterface
      where E#1,E#2 are type-variables:
        E#1 extends Object declared in interface List
        E#2 extends Object declared in interface MyInterface
    1 error
    

    これらのビルドエラーを修正するには、これらのインターフェースを実装するクラスで、互換性のある戻り値の型を持つメソッドをオーバーライドする必要があります。例:

    @Override
    public Object getFirst() {
        return List.super.getFirst();
    }
    

セキュリティ

Android 15 では、システムのセキュリティを強化し、悪意のあるアプリからアプリとユーザーを保護するための変更が加えられています。

制限付きの TLS バージョン

Android 15 限制了对 TLS 版本 1.0 和 1.1 的使用。这些版本之前已在 Android 中被弃用,但现在不允许面向 Android 15 的应用使用。

保護されたバックグラウンド アクティビティの起動

Android 15 では、悪意のあるアプリからユーザーを保護し、より細かく 悪意のあるバックグラウンド アプリが悪意のあるアクティビティを 他のアプリをフォアグラウンドで動作させる、権限昇格させる、アプリを悪用する です。バックグラウンド アクティビティの起動は、それ以降、 Android 10(API レベル 29)。

スタックの最上位の UID と一致しないアプリによるアクティビティの起動をブロックする

悪意のあるアプリは、同じタスク内で別のアプリのアクティビティを起動し、 そのアプリであるかのように見せかけます。この「タスク」は、 ハイジャック」現在のバックグラウンド起動の制限をバイパスできます。 同じ表示タスク内で発生します。このリスクを軽減するため、Android 15 では スタックの最上位の UID と一致しないアプリの起動をブロックするフラグ できます。アプリのすべてのアクティビティをオプトインするには、 allowCrossUidActivitySwitchFromBelow 属性を AndroidManifest.xml ファイル内で指定する必要があります。

<application android:allowCrossUidActivitySwitchFromBelow="false" >

次の条件がすべて満たされている場合、新しいセキュリティ対策は有効です。

  • リリースを実行するアプリは Android 15 をターゲットとしています。
  • タスクスタックの一番上にあるアプリは Android 15 をターゲットとしています。
  • 表示されているアクティビティはすべて、新しい保護設定にオプトインしています。

セキュリティ対策が有効になっている場合、アプリは 最後に表示されたアプリ(ユーザーが自身のタスクを完了した場合)

その他の変更点

UID マッチングの制限以外にも、次のような変更があります。 含まれるもの:

  • PendingIntent のクリエイターを変更してバックグラウンド アクティビティの起動をブロックするよう変更する デフォルトです。これにより、アプリが誤って IP アドレスを PendingIntent: 悪意のある人物によって悪用されるおそれがあります。
  • PendingIntent の送信者がない限りアプリをフォアグラウンドに戻さない 許可します。この変更は、悪意のあるアプリによって バックグラウンドでアクティビティを開始する機能。デフォルトでは、アプリが クリエイターが許可しない限り、タスクスタックをフォアグラウンドに移すことができる バックグラウンド アクティビティの起動権限がある、または送信者にバックグラウンド アクティビティがある できます。
  • タスクスタックのトップ アクティビティがタスクを終了する方法を制御する。もし 上位のアクティビティがタスクを終了すると、Android は 最後のアクティブな状態。さらに、トップ以外のアクティビティがそのタスクを完了すると、Android は ホーム画面に戻ります。このノントップ スレッドの できます。
  • 他のアプリから自分のアクティビティに任意のアクティビティを起動できないようにする タスクです。この変更により、悪意のあるアプリがユーザーをフィッシング攻撃から 他のアプリからと思われるアクティビティ
  • 非表示のウィンドウがバックグラウンド アクティビティの対象とみなされないようにブロックする 。これにより、悪意のあるアプリによるバックグラウンドの不正使用を防ぐことができます 望ましくないコンテンツや悪意のあるコンテンツをユーザーに表示する。

より安全なインテント

Android 15 では、インテントをより安全かつ堅牢にするために、新しいオプションのセキュリティ対策が導入されています。この変更は、悪意のあるアプリによって悪用されるおそれのある潜在的な脆弱性やインテントの不正使用を防止することを目的としています。Android 15 では、インテントのセキュリティに関して、主に 2 つの改善点があります。

  • ターゲットのインテント フィルタに一致させる: 特定のコンポーネントをターゲットとするインテントは、ターゲットのインテント フィルタの仕様に正確に一致する必要があります。別のアプリのアクティビティを起動するためのインテントを送信する場合、ターゲット インテント コンポーネントは、受信側のアクティビティで宣言されたインテント フィルタと一致している必要があります。
  • インテントにはアクションが必要です。アクションのないインテントは、インテント フィルタと一致しなくなります。つまり、アクティビティやサービスを起動するために使用するインテントには、明確に定義されたアクションが必要です。

アプリがこれらの変更にどのように対応するかを確認するには、アプリで StrictMode を使用します。Intent の使用違反に関する詳細なログを表示するには、次のメソッドを追加します。

KotlinJava

fun onCreate() {
   
StrictMode.setVmPolicy(VmPolicy.Builder()
       
.detectUnsafeIntentLaunch()
       
.build()
   
)
}


public void onCreate() {
   
StrictMode.setVmPolicy(new VmPolicy.Builder()
           
.detectUnsafeIntentLaunch()
           
.build());
}

ユーザー エクスペリエンスとシステム UI

Android 15 には、より一貫性があり直感的なユーザー エクスペリエンスを実現するための変更がいくつか含まれています。

ウィンドウの切れ込みの変更

Android 15 では、ウィンドウの切り欠きに関連する 2 つの変更があります。エッジツーエッジがデフォルトで適用され、システムバーのデフォルト構成などの構成も変更されています。

全面实施政策

Apps are edge-to-edge by default on devices running Android 15 if the app is targeting Android 15 (API level 35).

An app that targets Android 14 and is not edge-to-edge on an Android 15 device.


An app that targets Android 15 (API level 35) and is edge-to-edge on an Android 15 device. This app mostly uses Material 3 Compose Components that automatically apply insets. This screen is not negatively impacted by the Android 15 edge-to-edge enforcement.

This is a breaking change that might negatively impact your app's UI. The changes affect the following UI areas:

  • Gesture handle navigation bar
    • Transparent by default.
    • Bottom offset is disabled so content draws behind the system navigation bar unless insets are applied.
    • setNavigationBarColor and R.attr#navigationBarColor are deprecated and don't affect gesture navigation.
    • setNavigationBarContrastEnforced and R.attr#navigationBarContrastEnforced continue to have no effect on gesture navigation.
  • 3-button navigation
    • Opacity set to 80% by default, with color possibly matching the window background.
    • Bottom offset disabled so content draws behind the system navigation bar unless insets are applied.
    • setNavigationBarColor and R.attr#navigationBarColor are set to match the window background by default. The window background must be a color drawable for this default to apply. This API is deprecated but continues to affect 3-button navigation.
    • setNavigationBarContrastEnforced and R.attr#navigationBarContrastEnforced is true by default, which adds an 80% opaque background across 3-button navigation.
  • Status bar
    • Transparent by default.
    • The top offset is disabled so content draws behind the status bar unless insets are applied.
    • setStatusBarColor and R.attr#statusBarColor are deprecated and have no effect on Android 15.
    • setStatusBarContrastEnforced and R.attr#statusBarContrastEnforced are deprecated but still have an effect on Android 15.
  • Display cutout
    • layoutInDisplayCutoutMode of non-floating windows must be LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS. SHORT_EDGES, NEVER, and DEFAULT are interpreted as ALWAYS so that users don't see a black bar caused by the display cutout and appear edge-to-edge.

The following example shows an app before and after targeting Android 15 (API level 35), and before and after applying insets.

An app that targets Android 14 and is not edge-to-edge on an Android 15 device.
An app that targets Android 15 (API level 35) and is edge-to-edge on an Android 15 device. However, many elements are now hidden by the status bar, 3-button navigation bar, or display cutout due to the Android 15 edge-to-edge enforcements. Hidden UI includes the Material 2 top app bar, floating action buttons, and list items.
An app that targets Android 15 (API level 35), is edge to edge on an Android 15 device and applies insets so that UI is not hidden.
What to check if your app is already edge-to-edge

If your app is already edge-to-edge and applies insets, you are mostly unimpacted, except in the following scenarios. However, even if you think you aren't impacted, we recommend you test your app.

  • You have a non-floating window, such as an Activity that uses SHORT_EDGES, NEVER or DEFAULT instead of LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS. If your app crashes on launch, this might be due to your splashscreen. You can either upgrade the core splashscreen dependency to 1.2.0-alpha01 or later or set window.attributes.layoutInDisplayCutoutMode = WindowManager.LayoutInDisplayCutoutMode.always.
  • There might be lower-traffic screens with occluded UI. Verify these less-visited screens don't have occluded UI. Lower-traffic screens include:
    • Onboarding or sign-in screens
    • Settings pages
What to check if your app is not already edge-to-edge

If your app is not already edge-to-edge, you are most likely impacted. In addition to the scenarios for apps that are already edge-to-edge, you should consider the following:

  • If your app uses Material 3 Components ( androidx.compose.material3) in compose, such as TopAppBar, BottomAppBar, and NavigationBar, these components are likely not impacted because they automatically handle insets.
  • If your app is using Material 2 Components ( androidx.compose.material) in Compose, these components don't automatically handle insets. However, you can get access to the insets and apply them manually. In androidx.compose.material 1.6.0 and later, use the windowInsets parameter to apply the insets manually for BottomAppBar, TopAppBar, BottomNavigation, and NavigationRail. Likewise, use the contentWindowInsets parameter for Scaffold.
  • If your app uses views and Material Components (com.google.android.material), most views-based Material Components such as BottomNavigationView, BottomAppBar, NavigationRailView, or NavigationView, handle insets and require no additional work. However, you need to add android:fitsSystemWindows="true" if using AppBarLayout.
  • For custom composables, apply the insets manually as padding. If your content is within a Scaffold, you can consume insets using the Scaffold padding values. Otherwise, apply padding using one of the WindowInsets.
  • If your app is using views and BottomSheet, SideSheet or custom containers, apply padding using ViewCompat.setOnApplyWindowInsetsListener. For RecyclerView, apply padding using this listener and also add clipToPadding="false".
What to check if your app must offer custom background protection

If your app must offer custom background protection to 3-button navigation or the status bar, your app should place a composable or view behind the system bar using WindowInsets.Type#tappableElement() to get the 3-button navigation bar height or WindowInsets.Type#statusBars.

Additional edge-to-edge resources

See the Edge to Edge Views and Edge to Edge Compose guides for additional considerations on applying insets.

Deprecated APIs

The following APIs are deprecated but not disabled:

The following APIs are deprecated and disabled:

稳定配置

アプリが Android 15(API レベル 35)以降をターゲットとしている場合、Configuration はシステムバーを除外しなくなりました。Android 10 の Configuration クラスをレイアウト計算に使用するのではなく、 適切な ViewGroupWindowInsets、または 必要に応じて WindowMetricsCalculator

Configuration は API 1 以降で使用できます。通常は Activity.onConfigurationChanged。ウィンドウの密度、向き、サイズなどの情報を提供します。ウィンドウサイズに関する重要な特性の 1 つは Configuration から返されたのは、以前にシステムバーを除外していた点です。

構成サイズは通常、次のようなリソースの選択に使用されます。 /res/layout-h500dp であり、これも有効なユースケースです。ただし、 レイアウトの計算は常に推奨されません。その場合は、 今から離れていきましょう。Configuration の使用を次の内容に置き換える必要があります。 より適したモデルを選択できます。

レイアウトの計算に使用する場合は、CoordinatorLayoutConstraintLayout などの適切な ViewGroup を使用します。高さの値の計算に使用すると システム ナビゲーション バーの WindowInsets を使用します。現在のサイズを確認するには computeCurrentWindowMetrics を使用します。

この変更の影響を受けるフィールドは次のとおりです。

  • Configuration.screenWidthDpscreenHeightDp のサイズが廃止されました システムバーを除外します
  • Configuration.smallestScreenWidthDp は、screenWidthDpscreenHeightDp の変更によって間接的に影響を受けます。
  • 次の変更による間接的な影響: Configuration.orientation 正方形に近いデバイスの screenWidthDpscreenHeightDp
  • Display.getSize(Point) は、Configuration の変更によって間接的に影響を受けます。これは API レベル 30 以降で非推奨になりました。
  • Display.getMetrics() は、API レベル 33 以降、すでにこのように動作しています。

elegantTextHeight 属性のデフォルトは true

对于以 Android 15(API 级别 35)为目标平台的应用,elegantTextHeight TextView 属性默认会变为 true,将默认使用的紧凑字体替换为一些具有较大垂直测量的脚本,使其更易于阅读。紧凑字体旨在防止布局中断;Android 13(API 级别 33)允许文本布局利用 fallbackLineSpacing 属性拉伸垂直高度,从而防止许多此类中断。

在 Android 15 中,系统中仍保留了紧凑字体,因此您的应用可以将 elegantTextHeight 设置为 false 以获得与之前相同的行为,但即将发布的版本不太可能支持此字体。因此,如果您的应用支持以下脚本:阿拉伯语、老挝语、缅甸语、泰米尔语、古吉拉特语、卡纳达语、马拉雅拉姆语、奥里亚语、泰卢固语或泰语,请将 elegantTextHeight 设置为 true 以测试您的应用。

针对以 Android 14(API 级别 34)及更低版本为目标平台的应用的 elegantTextHeight 行为。
以 Android 15 为目标平台的应用的 elegantTextHeight 行为。

複雑な文字の形状で TextView の幅が変更される

Android の以前のバージョンでは、複雑なシェーピングを持つ一部の筆記体フォントや言語では、文字が前の文字または次の文字の領域に描画されることがあります。場合によっては、このような文字の開始位置や終了位置が切り詰められていました。Android 15 以降では、TextView はこのような文字に十分なスペースを描画するための幅を割り当て、アプリがクリッピングを防ぐために左側に追加の余白をリクエストできるようにします。

この変更は TextView が幅を決定する方法に影響するため、アプリが Android 15(API レベル 35)以降をターゲットとしている場合、TextView はデフォルトでより多くの幅を割り当てます。この動作を有効または無効にするには、TextViewsetUseBoundsForWidth API を呼び出します。

左側の余白を追加すると、既存のレイアウトの位置がずれる可能性があるため、Android 15 以降をターゲットとするアプリでも、デフォルトでは余白は追加されません。ただし、setShiftDrawingOffsetForStartOverhang を呼び出すことで、クリッピングを防ぐためにパディングを追加できます。

次の例は、これらの変更によって、一部のフォントと言語のテキスト レイアウトがどのように改善されるかを示しています。

英語のテキストを筆記体フォントで表示する場合の標準レイアウト。一部の文字が切り取られている。対応する XML は次のとおりです。

<TextView
    android:fontFamily="cursive"
    android:text="java" />
同じ英語のテキストのレイアウト。幅とパディングが追加されています。対応する XML は次のとおりです。

<TextView
    android:fontFamily="cursive"
    android:text="java"
    android:useBoundsForWidth="true"
    android:shiftDrawingOffsetForStartOverhang="true" />
タイ語テキストの標準レイアウト。一部の文字が切り取られている。 対応する XML は次のとおりです。

<TextView
    android:text="คอมพิวเตอร์" />
幅とパディングを追加した、同じタイ語のテキストのレイアウト。対応する XML は次のとおりです。

<TextView
    android:text="คอมพิวเตอร์"
    android:useBoundsForWidth="true"
    android:shiftDrawingOffsetForStartOverhang="true" />

言語 / 地域に応じた EditText のデフォルトの行の高さ

在较低版本的 Android 中,文本布局会拉伸文本的高度,以满足与当前语言区域匹配的字体的行高。例如,如果内容是日语,由于日语字体的行高略高于拉丁字体,因此文本的高度会略高。不过,尽管行高存在这些差异,但无论使用的是哪种语言区域,EditText 元素的大小都是统一的,如下图所示:

三个框,表示可以包含英语 (en)、日语 (ja) 和缅甸语 (my) 文本的 EditText 元素。EditText 的高度相同,即使这些语言的行高各不相同。

对于以 Android 15(API 级别 35)为目标平台的应用,现在为 EditText 预留了最小行高,以匹配指定语言区域的参考字体,如下图所示:

三个框,表示可以包含英语 (en)、日语 (ja) 和缅甸语 (my) 文本的 EditText 元素。EditText 的高度现在包含足够的空间来容纳这些语言字体的默认行高。

如有需要,您的应用可以将 useLocalePreferredLineHeightForMinimum 属性指定为 false,以恢复之前的行为;您的应用还可以在 Kotlin 和 Java 中使用 setMinimumFontMetrics API 设置自定义最小垂直指标。

カメラとメディア

Android 15 では、Android 15 以降をターゲットとするアプリのカメラとメディアの動作が次のように変更されます。

音声フォーカスのリクエストに関する制限

Android 15(API レベル 35)をターゲットとするアプリが音声フォーカスをリクエストするには、最上位のアプリであるか、フォアグラウンド サービスを実行している必要があります。アプリがこれらの要件のいずれかを満たしていないときにフォーカスをリクエストしようとすると、呼び出しは AUDIOFOCUS_REQUEST_FAILED を返します。

音声フォーカスの詳細については、音声フォーカスを管理するをご覧ください。

非 SDK の制限の更新

Android 15 では、Android デベロッパーの協力と直近の内部テストに基づいて、制限を受ける非 SDK インターフェースのリストが更新されています。Google は、非 SDK インターフェースを制限する前に、可能な限り、その代わりとなる公開インターフェースを利用可能にしています。

Android 15 をターゲットとしないアプリでは、この変更の一部はすぐには影響しない可能性があります。ただし、アプリのターゲット API レベルによっては、アプリが一部非 SDK インターフェースにアクセスできる場合もありますが、非 SDK のメソッドやフィールドを使用すると、アプリが機能しなくなるリスクが高くなります。

アプリが非 SDK インターフェースを使用しているかどうか不明な場合は、アプリをテストして確認できます。アプリが非 SDK インターフェースに依存している場合は、SDK の代替インターフェースへの移行を計画してください。ただし Google も、一部のアプリには非 SDK インターフェースを使用する正当なユースケースがあると承知しています。アプリの機能に使用している非 SDK インターフェースの代わりが見つからない場合は、新しい公開 API をリクエストしてください。

如需详细了解此 Android 版本中的变更,请参阅 Android 15 中有关限制非 SDK 接口的更新。如需全面了解有关非 SDK 接口的详细信息,请参阅对非 SDK 接口的限制