パフォーマンス クラスは、Android 12 で初めて導入された規格です。パフォーマンス クラスは、Android の基本要件を超えるデバイス機能のセットを定義します。
Android のバージョンごとに、対応する独自のパフォーマンス クラスがあります。これはそのバージョンの Android 互換性定義ドキュメント(CDD)で規定されています。Android 互換性テストスイート(CTS)で、CDD の要件を検証します。
各 Android 搭載デバイスは、サポート対象のパフォーマンス クラスを宣言します。デベロッパーは実行時にデバイスのパフォーマンス クラスを検出し、デバイスの機能を最大限に活用するアップグレード環境を提供できます。
デバイスのパフォーマンス クラス レベルを検出するには、Jetpack の Core Performance ライブラリを使用します。このライブラリは、ビルド バージョン情報での宣言、または Google Play 開発者サービスのデータに基づいて、デバイスのメディア パフォーマンス クラス(MPC)レベルをレポートします。
まず、Gradle ファイルに、関連するモジュールの依存関係を追加します。
// Implementation of Jetpack Core library. implementation("androidx.core:core-ktx:1.12.0") // Enable APIs to query for device-reported performance class. implementation("androidx.core:core-performance:1.0.0") // Enable APIs to query Google Play services for performance class. implementation("androidx.core:core-performance-play-services:1.0.0")
// Implementation of Jetpack Core library. implementation 'androidx.core:core-ktx:1.12.0' // Enable APIs to query for device-reported performance class. implementation 'androidx.core:core-performance:1.0.0' // Enable APIs to query Google Play services for performance class. implementation 'androidx.core:core-performance-play-services:1.0.0'