AI-generated Key Takeaways
-
Google Mobile Ads SDK (beta) requires passing the AdMob ad unit ID directly to the
AdRequestobject instead of the load ad method. -
The method for passing extra parameters to AdMob for requests like non-personalized ads has changed.
-
The method for passing extra parameters to an ad source adapter has been updated to use
putAdSourceExtrasBundle.
This page covers the instructions to migrate ad requests.
Google Mobile Ads SDK (beta) requires you to pass the
AdMob ad unit ID directly to the AdRequest object,
rather than passing it to the load ad method.
| Current |
Kotlinval adRequest = AdRequest.Builder().build() InterstitialAd.load( this, "AD_UNIT_ID", adRequest, object : InterstitialAdLoadCallback() { } ) JavaAdRequest adRequest = new AdRequest.Builder().build(); InterstitialAd.load( this, "AD_UNIT_ID", adRequest, new InterstitialAdLoadCallback() { } ); |
| Google Mobile Ads SDK (beta) |
Kotlinval adRequest = AdRequest.Builder("AD_UNIT_ID").build() InterstitialAd.load(adRequest, object : AdLoadCallback<InterstitialAd> {}) JavaAdRequest adRequest = new AdRequest.Builder("AD_UNIT_ID").build(); InterstitialAd.load(adRequest, new AdLoadCallback<InterstitialAd>() {}); |
Pass extra parameters to AdMob
The following examples pass extra parameters to AdMob to request non-personalized ads:
| Current |
Kotlinval extras = Bundle() extras.putInt("npa", 1) val request = AdRequest.Builder() .addNetworkExtrasBundle(AdMobAdapter::class.java, extras) .build() JavaBundle extras = new Bundle(); extras.putInt("npa", 1); AdRequest request = new AdRequest.Builder() .addNetworkExtrasBundle(AdMobAdapter.class, extras) .build(); |
| Google Mobile Ads SDK (beta) |
Kotlinval extras = Bundle() extras.putInt("npa", 1) val request = AdRequest.Builder("AD_UNIT_ID") .setGoogleExtrasBundle(extras) .build() JavaBundle extras = new Bundle(); extras.putInt("npa", 1); AdRequest request = new AdRequest.Builder("AD_UNIT_ID") .setGoogleExtrasBundle(extras) .build(); |
Pass extra parameters to an ad source adapter
The following examples pass extra parameters to a sample ad source adapter. For details on passing extra parameters to a specific ad source adapter, see the corresponding ad source integration guide.
| Current |
Kotlinval extras = Bundle() extras.putString("exampleKey", "exampleValue") val request = AdRequest.Builder() .addNetworkExtrasBundle(SampleAdapter::class, extras) .build() JavaBundle extras = new Bundle(); extras.putString("exampleKey", "exampleValue"); AdRequest request = new AdRequest.Builder() .addNetworkExtrasBundle(SampleAdapter.class, extras) .build(); |
| Google Mobile Ads SDK (beta) |
Kotlinval extras = Bundle() extras.putString("exampleKey", "exampleValue") val request = AdRequest.Builder("AD_UNIT_ID") .putAdSourceExtrasBundle(SampleAdapter::class.java, extras) .build() JavaBundle extras = new Bundle(); extras.putString("exampleKey", "exampleValue"); AdRequest request = new AdRequest.Builder("AD_UNIT_ID") .putAdSourceExtrasBundle(SampleAdapter.class, extras) .build(); |