This page covers the instructions to migrate ad requests.
The Next Gen Mobile Ads SDK 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() { } ); |
Next Gen |
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 in the current and Next Gen Mobile Ads SDKs 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(); |
Next Gen |
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 in the current and Next Gen Mobile Ads SDKs. 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(); |
Next Gen |
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(); |