クイック スタートガイドでは、Google Mobile Ads SDK を初期化する方法を説明します。この初期化の呼び出し中に、メディエーション アダプタも初期化されます。最初の広告リクエストにすべての広告ネットワークが参加していることを確認するため、広告を読み込むのは初期化が完了するまで待ってからにしてください。
次のサンプルコードは、広告リクエストを行う前に各アダプタの初期化状況を確認する方法を示しています。
Java
publicvoidinitialize(Contextcontext){newThread(()->
// Initialize the Google Mobile Ads SDK on a background thread.MobileAds.initialize(context,this::logAdapterStatus)).start();}privatevoidlogAdapterStatus(InitializationStatusinitializationStatus){// Check each adapter's initialization status.Map<String,AdapterStatus>statusMap=initializationStatus.getAdapterStatusMap();for(Map.Entry<String,AdapterStatus>entry:statusMap.entrySet()){StringadapterClass=entry.getKey();AdapterStatusstatus=entry.getValue();Log.d(TAG,String.format("Adapter name: %s, Description: %s, Latency: %d",adapterClass,status.getDescription(),status.getLatency()));}}
funinitialize(context:Context){CoroutineScope(Dispatchers.IO).launch{// Initialize the Google Mobile Ads SDK on a background thread.MobileAds.initialize(context,::logAdapterStatus)}}privatefunlogAdapterStatus(initializationStatus:InitializationStatus){// Check each adapter's initialization status.for((adapterClass,status)ininitializationStatus.adapterStatusMap){Log.d(TAG,"Adapter: $adapterClass, Status: ${status.description}, Latency: ${status.latency}ms",)}}
ResponseInforesponseInfo=ad.getResponseInfo();StringadapterClassName=null;if(responseInfo!=null){adapterClassName=responseInfo.getMediationAdapterClassName();}Log.d(TAG,"Adapter class name: "+adapterClassName);
[null,null,["最終更新日 2025-08-31 UTC。"],[[["\u003cp\u003eThis guide explains how to integrate a mediation adapter with your Android app to display ads from various ad networks.\u003c/p\u003e\n"],["\u003cp\u003eBefore integrating mediation, ensure you've integrated the desired ad formats (banner, interstitial, native, rewarded, rewarded interstitial) into your app.\u003c/p\u003e\n"],["\u003cp\u003eInitialize the Mobile Ads SDK, allowing mediation adapters to initialize, and confirm their status before making ad requests for optimal ad network participation.\u003c/p\u003e\n"],["\u003cp\u003eWhen using banner ads with mediation, disable refresh in third-party ad source UIs to avoid double refreshing.\u003c/p\u003e\n"],["\u003cp\u003eFor compliance with U.S. state privacy laws or GDPR, add your mediation partners in Ad Manager's Privacy & Messaging settings to ensure ad serving capabilities.\u003c/p\u003e\n"]]],[],null,["# Get started\n\n\u003cbr /\u003e\n\nThis guide shows you how to integrate a mediation adapter with your\nAndroid app.\n\nPrerequisites\n-------------\n\nBefore you can integrate mediation for an ad format, you need to integrate that\nad format into your app:\n\n- [Banner Ads](/ad-manager/mobile-ads-sdk/android/banner)\n- [Interstitial Ads](/ad-manager/mobile-ads-sdk/android/interstitial)\n- [Native Ads](/ad-manager/mobile-ads-sdk/android/native)\n- [Rewarded Ads](/ad-manager/mobile-ads-sdk/android/rewarded)\n- [Rewarded Interstitial\n Ads](/ad-manager/mobile-ads-sdk/android/rewarded-interstitial)\n\nNew to mediation? Read\n\n[Introduction to mediation](//support.google.com/admanager/answer/6272813).\n\nFor bidding:\n\nGoogle Mobile Ads SDK 18.3.0\nor higher.\n\nInitialize\nGoogle Mobile Ads SDK\n--------------------------------\n\nThe quick start guide shows you how to [initialize the\nGoogle Mobile Ads SDK](/ad-manager/mobile-ads-sdk/android/quick-start#initialize_the_mobile_ads_sdk).\nDuring that initialization call, mediation adapters also\nget initialized. It is important to wait for initialization to complete before\nyou load ads in order to verify full participation from every ad network on the\nfirst ad request.\n| **Important:** Bidding adapters require you to explicitly initialize Google Mobile Ads SDK .\n\nThe following sample code shows how you can check each adapter's initialization\nstatus prior to making an ad request. \n\n### Java\n\n public void initialize(Context context) {\n new Thread(\n () -\u003e\n // Initialize the Google Mobile Ads SDK on a background thread.\n MobileAds.initialize(context, this::logAdapterStatus))\n .start();\n }\n\n private void logAdapterStatus(InitializationStatus initializationStatus) {\n // Check each adapter's initialization status.\n Map\u003cString, AdapterStatus\u003e statusMap = initializationStatus.getAdapterStatusMap();\n for (Map.Entry\u003cString, AdapterStatus\u003e entry : statusMap.entrySet()) {\n String adapterClass = entry.getKey();\n AdapterStatus status = entry.getValue();\n Log.d(\n TAG,\n String.format(\n \"Adapter name: %s, Description: %s, Latency: %d\",\n adapterClass, status.getDescription(), status.getLatency()));\n }\n } \n https://github.com/googleads/googleads-mobile-android-examples/blob/ccc290a583d7f552bdcf81ea76adc05beaa43f0b/java/advanced/APIDemo/app/src/main/java/com/google/android/gms/snippets/MediationSnippets.java#L30-L50\n\n### Kotlin\n\n fun initialize(context: Context) {\n CoroutineScope(Dispatchers.IO).launch {\n // Initialize the Google Mobile Ads SDK on a background thread.\n MobileAds.initialize(context, ::logAdapterStatus)\n }\n }\n\n private fun logAdapterStatus(initializationStatus: InitializationStatus) {\n // Check each adapter's initialization status.\n for ((adapterClass, status) in initializationStatus.adapterStatusMap) {\n Log.d(\n TAG,\n \"Adapter: $adapterClass, Status: ${status.description}, Latency: ${status.latency}ms\",\n )\n }\n } \n https://github.com/googleads/googleads-mobile-android-examples/blob/ccc290a583d7f552bdcf81ea76adc05beaa43f0b/kotlin/advanced/APIDemo/app/src/main/java/com/google/android/gms/snippets/MediationSnippets.kt#L25-L41\n\nCheck which ad network adapter class loaded the ad\n--------------------------------------------------\n\nHere is some sample code that logs the ad network class name for a banner ad: \n\n### Java\n\n ResponseInfo responseInfo = ad.getResponseInfo();\n String adapterClassName = null;\n if (responseInfo != null) {\n adapterClassName = responseInfo.getMediationAdapterClassName();\n }\n Log.d(TAG, \"Adapter class name: \" + adapterClassName); \n https://github.com/googleads/googleads-mobile-android-examples/blob/ccc290a583d7f552bdcf81ea76adc05beaa43f0b/java/advanced/APIDemo/app/src/main/java/com/google/android/gms/snippets/ResponseInfoSnippets.java#L46-L51\n\n### Kotlin\n\n Log.d(TAG, \"Adapter class name:\" + ad.responseInfo?.mediationAdapterClassName) \n https://github.com/googleads/googleads-mobile-android-examples/blob/ccc290a583d7f552bdcf81ea76adc05beaa43f0b/kotlin/advanced/APIDemo/app/src/main/java/com/google/android/gms/snippets/ResponseInfoSnippets.kt#L42-L42\n\nRefer to the `ResponseInfo` documentation on `getMediationAdapterClassName()`\nfor details about this method.\n\nInitialize your ad object with an Activity instance\n---------------------------------------------------\n\nIn the constructor for a new ad object (for example,\n\n[`AdManagerAdView`](/ad-manager/mobile-ads-sdk/android/reference/com/google/android/gms/ads/admanager/AdManagerAdView)),\n\nyou must pass in an object of type\n[`Context`](//developer.android.com/reference/android/content/Context.html).\nThis `Context` is passed on to other ad networks when using mediation. Some\nad networks require a more restrictive `Context` that is of type\n[`Activity`](//developer.android.com/reference/android/app/Activity.html)\nand may not be able to serve ads without an `Activity` instance. Therefore,\nwe recommend passing in an `Activity` instance when initializing ad objects\nto verify a consistent experience with your mediated ad networks.\n\n\u003cbr /\u003e\n\nUse banner ads with mediation\n-----------------------------\n\nMake sure to disable refresh in all third-party ad source UIs for banner ad\nunits used in mediation. This prevents a\ndouble refresh since Ad Manager also triggers a refresh\nbased on your banner ad unit's refresh rate.\n\nUse native ads with mediation\n-----------------------------\n\nThe following are some best practices to consider when implementing native\nmediation.\n\nNative ad presentation policy\n: Each ad network has its own policies. When using mediation, it's important to\n remember that your app still needs to abide by the policies of the mediated\n network that provided the ad.\n\nUse `loadAd()` instead of `loadAds()`\n: The `loadAds()` method serves only Google ads. For mediated ads, use\n `loadAd()` instead.\n\nUS states privacy laws and GDPR\n-------------------------------\n\nIf you need to comply with the [U.S. states privacy\nlaws](//support.google.com/admanager/answer/9561023) or [General Data Protection\nRegulation (GDPR)](//support.google.com/admanager/answer/7666366), follow the\nsteps in [US state regulations\nsettings](//support.google.com/admanager/answer/10115735) or [GDPR\nsettings](//support.google.com/admanager/answer/10113006#adding_ad_partners_to_published_gdpr_messages) to add your\nmediation partners in Ad Manager Privacy \\& messaging's\nUS states or GDPR ad partners list. Failure to do so can lead to partners\nfailing to serve ads on your app.\n\nLearn more about enabling [restricted data processing\n(RDP)](/ad-manager/mobile-ads-sdk/android/privacy/us-states) and obtaining GDPR consent with the\n[Google User Messaging Platform (UMP) SDK](/ad-manager/mobile-ads-sdk/android/privacy)."]]