IMA の読み込み時間を短縮
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
IMA SDK は、広告のリクエスト、視認性の測定、広告インプレッションのレポート作成に必要な依存関係を読み込みます。広告リクエストを行う前に IMA を初期化することで、広告再生前に IMA の依存関係を読み込む時間を最大限に確保できます。このページでは、アプリで IMA の読み込み時間を処理する方法について説明します。
ImaSdkFactory.initialize()
に電話
ImaSdkFactory.initialize()
メソッドは、最初の広告リクエストの前に SDK リソースのプリロードを開始します。initialize()
を使用するには、IMA バージョン 3.35.1 以降が必要です。
アプリの起動時、またはアプリの構造で許容される限り早い段階で、ImaSdkFactory.initialize()
を呼び出します。initialize()
呼び出しは、次のパラメータを受け取ります。
context
: アプリケーションのライフサイクル中に常に利用可能なアプリケーション コンテキストを使用します。
settings
: 値が設定された ImaSdkSettings
オブジェクトを渡します。initialize()
呼び出しで使用される IMA 設定は、createAdsLoader()
呼び出しで使用される設定値と同じである必要があります。IMA SDK は、これらの設定(特に言語設定)をキャッシュキーに使用します。initialize()
メソッド呼び出しで使用される設定にテスト値や偽の値を使用することはおすすめしません。キャッシュミスが発生し、広告の読み込み時間が長くなる可能性があります。
AdsLoader
インスタンスを再利用する
IMA の読み込み時間を短縮するには、同じ AdsLoader
インスタンスを再利用することをおすすめします。AdsLoader
インターフェースは、複数の広告リクエストまたはストリーム リクエストを処理できます。リクエストごとに新しい AdsLoader
インスタンスを作成しないようにします。新しい AdsLoader
インスタンスを作成するには読み込み時間が必要で、追加のデバイス リソースが使用されます。
再生前に広告をリクエストする
広告の再生を開始する前に AdsLoader
インスタンスにアクセスできる場合は、AdsLoader.requestAds()
メソッドを早めに呼び出すこともできます。この呼び出しを行うと、プレロール広告の読み込みが開始されます。ユーザーがコンテンツの再生を開始する準備ができたら、AdsManager.init()
メソッドを呼び出し、LOADED
イベントを待って広告を再生します。
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-09-05 UTC。
[null,null,["最終更新日 2025-09-05 UTC。"],[],[],null,["# Improve IMA load time\n\nThe IMA SDK loads dependencies to request ads, measure viewability and\nreport ad impressions. By initializing IMA before you make an ad request, you\nmaximize the time to load IMA dependencies before ad playback. This page covers\nhow to handling IMA load times in your app.\n\nCall `ImaSdkFactory.initialize()`\n---------------------------------\n\nThe\n[`ImaSdkFactory.initialize()`](/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/ImaSdkFactory#initialize(android.content.Context,com.google.ads.interactivemedia.v3.api.ImaSdkSettings))\nmethod starts to preload SDK resources in advance of the first ad request. To\nuse `initialize()`, you need IMA version 3.35.1 or higher.\n\nCall `ImaSdkFactory.initialize()` on application startup, or as early in the\napplication's lifecycle as your app structure allows. The `initialize()` call\ntakes the following parameters:\n\n- **`context`**: Uses the application context, which is always available during the lifecycle of the application.\n- **`settings`** : Pass the an [`ImaSdkSettings`](/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/ImaSdkSettings) object with its values set. The IMA settings used in the `initialize()` call must be the same as the settings values used in the `createAdsLoader()` call. The IMA SDK utilizes these settings, particularly the language setting, for cache key. We don't recommend using test or fake values for the settings used in the `initialize()` method call, as cache misses might occur and increase ad load time.\n\nReuse the `AdsLoader` instance\n------------------------------\n\nTo improve IMA load time, we recommend you reuse the same\n[`AdsLoader`](/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdsLoader)\ninstance. The `AdsLoader` interface can handle multiple ad or stream requests.\nAvoid creating a new `AdsLoader` instance for each request. Creating a new\n`AdsLoader` instance requires a load time, and uses additional device resources.\n\nRequest ads in advance of playback\n----------------------------------\n\nIf you have access to the `AdsLoader` instance prior to starting ad playback,\nyou can also call the\n[`AdsLoader.requestAds()`](/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdsLoader#requestAds(com.google.ads.interactivemedia.v3.api.AdsRequest))\nmethod early. Making this call starts loading pre-roll ads. When the user\nis ready to start content playback, call the\n[`AdsManager.init()`](/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/BaseManager#init())\nmethod and wait for the `LOADED` event to play ads."]]