שיפור זמן הטעינה של IMA
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
ה-IMA SDK טוען יחסי תלות כדי לבקש מודעות, למדוד ניראות ולדווח על חשיפות של מודעות. כשמאתחלים את IMA לפני ששולחים בקשה להצגת מודעה, אפשר למקסם את הזמן לטעינת יחסי התלות של IMA לפני ההפעלה של המודעה. בדף הזה מוסבר איך לטפל בזמני הטעינה של IMA באפליקציה.
התקשרות אל ImaSdkFactory.initialize()
השיטה ImaSdkFactory.initialize()
מתחילה לטעון מראש משאבי SDK לפני הבקשה הראשונה להצגת מודעה. כדי להשתמש ב-initialize()
, צריך IMA מגרסה 3.35.1 ואילך.
צריך להפעיל את ImaSdkFactory.initialize()
בזמן ההפעלה של האפליקציה, או בשלב מוקדם ככל האפשר במחזור החיים של האפליקציה, בהתאם למבנה האפליקציה. הקריאה ל-initialize()
מקבלת את הפרמטרים הבאים:
context
: משתמש בהקשר של האפליקציה, שתמיד זמין במהלך מחזור החיים של האפליקציה.
settings
: מעבירים אובייקט ImaSdkSettings
עם הערכים שהוגדרו לו. הגדרות ה-IMA שנעשה בהן שימוש בקריאה initialize()
חייבות להיות זהות לערכי ההגדרות שנעשה בהם שימוש בקריאה createAdsLoader()
. IMA SDK משתמש בהגדרות האלה, במיוחד בהגדרת השפה, למפתח מטמון. לא מומלץ להשתמש בערכים לבדיקה או בערכים מזויפים להגדרות שמשמשות בקריאה ל-method initialize()
, כי יכול להיות שיחולו החמצות במטמון ויאריכו את זמן הטעינה של המודעות.
שימוש חוזר במכונה AdsLoader
כדי לשפר את זמן הטעינה של IMA, מומלץ לעשות שימוש חוזר באותו מכונה של AdsLoader
. הממשק AdsLoader
יכול לטפל במספר בקשות להצגת מודעות או להעברת סטרימינג.
מומלץ לא ליצור מכונה חדשה של AdsLoader
לכל בקשה. יצירת מכונה חדשה של AdsLoader
דורשת זמן טעינה ומשתמשת במשאבים נוספים במכשיר.
שליחת בקשה להצגת מודעות לפני ההפעלה
אם יש לכם גישה למכונה AdsLoader
לפני שתתחילו את ההפעלה של המודעה, תוכלו גם להפעיל את השיטה AdsLoader.requestAds()
מוקדם. הקריאה הזו מתחילה את טעינת המודעות לפני הסרטון (pre-roll). כשהמשתמש מוכן להתחיל את הפעלת התוכן, צריך להפעיל את השיטה AdsManager.init()
ולהמתין לאירוע LOADED
כדי להציג מודעות.
אלא אם צוין אחרת, התוכן של דף זה הוא ברישיון Creative Commons Attribution 4.0 ודוגמאות הקוד הן ברישיון Apache 2.0. לפרטים, ניתן לעיין במדיניות האתר Google Developers. Java הוא סימן מסחרי רשום של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-08-31 (שעון UTC).
[null,null,["עדכון אחרון: 2025-08-31 (שעון 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."]]