Improve IMA load time
Stay organized with collections
Save and categorize content based on your preferences.
The IMA SDK loads dependencies to request Dynamic Ad Insertion (DAI) streams,
measure viewability and report ad impressions. By initializing IMA before you
make a stream request, you maximize the time to load IMA dependencies before
stream playback. This page covers how to handling IMA load times in your app.
Call ImaSdkFactory.initialize()
The
ImaSdkFactory.initialize()
method starts to preload SDK resources in advance of the first stream request.
To use initialize()
, you need IMA version 3.35.1 or higher.
Call ImaSdkFactory.initialize()
on application startup, or as early in the
application's lifecycle as your app structure allows. The initialize()
call
takes the following parameters:
context
: Uses the application context, which is always available during
the lifecycle of the application.
settings
: Pass the an
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.
Reuse the AdsLoader
instance
To improve IMA load time, we recommend you reuse the same
AdsLoader
instance. The AdsLoader
interface can handle multiple ad or stream requests.
Avoid creating a new AdsLoader
instance for each request. Creating a new
AdsLoader
instance requires a load time, and uses additional device resources.
Request streams in advance of playback
If you have access to the AdsLoader
instance prior to starting stream
playback, you can also call the
AdsLoader.requestStream()
method early. Making this call starts loading the DAI stream. When the user
is ready to start stream playback, call the
StreamManager.init()
method to initialize stream playback.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-20 UTC.
[null,null,["Last updated 2025-08-20 UTC."],[],[],null,["# Improve IMA load time\n\nThe IMA SDK loads dependencies to request Dynamic Ad Insertion (DAI) streams,\nmeasure viewability and report ad impressions. By initializing IMA before you\nmake a stream request, you maximize the time to load IMA dependencies before\nstream playback. This page covers how to handling IMA load times in your app.\n\nCall `ImaSdkFactory.initialize()`\n---------------------------------\n\nThe\n[`ImaSdkFactory.initialize()`](/ad-manager/dynamic-ad-insertion/sdk/android/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 stream request.\nTo use `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`](/ad-manager/dynamic-ad-insertion/sdk/android/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 streams in advance of playback\n--------------------------------------\n\nIf you have access to the `AdsLoader` instance prior to starting stream\nplayback, you can also call the\n[`AdsLoader.requestStream()`](/ad-manager/dynamic-ad-insertion/sdk/android/api/reference/com/google/ads/interactivemedia/v3/api/AdsLoader#requestStream(com.google.ads.interactivemedia.v3.api.StreamRequest))\nmethod early. Making this call starts loading the DAI stream. When the user\nis ready to start stream playback, call the\n[`StreamManager.init()`](/ad-manager/dynamic-ad-insertion/sdk/android/api/reference/com/google/ads/interactivemedia/v3/api/BaseManager#init())\nmethod to initialize stream playback."]]