Enable AdMob Mediation on Android

Documentation for integrating AdMob Mediation with Vungle SDK resides on AdMob's Guide section, Integrating Vungle with Mediation, so use this guide as a supplement for the information about new features that are yet to be covered by the official documentation.

Download AdMob Android Adapter v.7.0.0.0 and include Vungle Android SDK v.7.0.0. You can add them to your project manually or do Gradle integration through Bintray.

implementation 'com.google.ads.mediation:vungle:7.0.0.0'
implementation 'com.vungle:vungle-ads:7.0.0'

Refer to the instructions for Android Studio integration and manual integration in AdMob's integration guide, Import the Vungle SDK and Adapter.

COPPA

Starting with Vungle SDK v6.10.3, Vungle provides an optional method for you to indicate to the Vungle SDK at the device level whether the user within the given mobile app is under or over the age of 13. The Vungle SDK COPPA configuration respects AdMob's "tag for child-directed treatment."

To learn more about Vungle's tools to assist publishers in complying with COPPA, as well as when to use the SDK COPPA API as opposed to the Dashboard COPPA settings, refer to our COPPA Implementation details.

SDK COPPA API

The COPPA status must be set before calling initializing the AdMob SDK, as shown:

RequestConfiguration configuration = MobileAds.getRequestConfiguration()
        .toBuilder()
        .setTagForChildDirectedTreatment(RequestConfiguration.TAG_FOR_CHILD_DIRECTED_TREATMENT_TRUE)
        // OR RequestConfiguration.TAG_FOR_CHILD_DIRECTED_TREATMENT_FALSE
        // OR RequestConfiguration.TAG_FOR_CHILD_DIRECTED_TREATMENT_UNSPECIFIED
        .build();
MobileAds.setRequestConfiguration(configuration);
    

CCPA

As of July 1, 2020, California Consumer Privacy Act (CCPA) will be enforced and publishers must update to Android SDK 6.7.0 and AdMob adapter 6.7.0.0 to comply with CCPA.

To pass CCPA values, you must call the Vungle SDK API directly. This  is the only feature that should be accessed directly through Vungle SDK API. Other optional features such as Android ID and memory settings should use VungleNetworkSettings.

Use VunglePrivacySettings.setCCPAStatus to set the user’s consent status to specify that the user has opted out by passing false. And use VunglePrivacySettings.getCCPAStatus to get the current CCPA status for the particular user.

CCPA API
VunglePrivacySettings.setCCPAStatus(true | false)
Sample Code
// To set the user's CCPA status to opted out:
VunglePrivacySettings.setCCPAStatus(false);
// To find out what the user's current consent status is("opted_in" | "opted_out"):
String currentCCPAStatus = VunglePrivacySettings.getCCPAStatus();

Banner Ads

Starting with v.6.5.1, Vungle SDK supports AdMob’s banner ads. To display a banner ad in the application, create an MREC or banner placement on the Monetize Dashboard and configure it to a banner ad unit on the AdMob dashboard. Note that MREC (300dp x 250dp) must have a separate placement reference ID configured as MREC from the Monetize dashboard, compared to other banner sizes configured as banner.

Supported banner sizes:

Size in dp (WxH) Description AdSize constant
320x50 Banner BANNER
728x90 IAB Leaderboard LEADERBOARD
300x250 IAB Medium Rectangle MEDIUM_RECTANGLE
Provided width x Adaptive height Adaptive banner N/A
Screen width x 32|50|90 Smart banner SMART_BANNER

Sample code:

AdView adView = new AdView(this);
adViews.add(adView);
adView.setAdSize(AdSize.MEDIUM_RECTANGLE);
adView.setAdUnitId();

Rewarded Interstitial Ads

As of AdMob Adapter 6.12.0.0, we support rewarded interstitial ads. This includes publisher and advertiser settings and controls, and reporting. Contact your Liftoff account manager to enable this feature. Rewarded interstitial ads behave as follows:

A user playing a game has just completed a level. While the next level loads, the user is prompted that an ad will begin in a few seconds and the reward for watching the ad is an extra heart. The user has the option to close the ad.

After a few seconds, the ad begins with a countdown informing the user of the time left until they receive the reward. If the user clicks to exit the ad, a prompt appears, warning them about the loss of the reward. The user must confirm that they want to exit the ad before the ad closes.

Our support for rewarded interstitial ads includes:

  • Skip ad option
  • Ad autostart (for example, after 5 seconds)
  • A close ad screen similar to what is displayed when a user tries to close a rewarded ad
  • An endcard when the video completes

If you opt of creating an introduction screen that displays when an ad is about to play, refer to the Google AdMob documentation for rewarded interstitials.

Network-Specific Parameters

The Vungle AdMob adapter continues to support network specific parameters as shown on AdMob's guide. Starting with v.6.5.1, audio setting for video play has been replaced by setStartMuted that takes a boolean and setSoundEnabled has been deprecated. The adapter also supports an additional parameter setAdOrientation to play the ad as per device orientation that takes an AdConfig object with LANDSCAPE, PORTRAIT, AUTO_ROTATE and MATCH_VIDEO configurability (setAutoRotate has been deprecated).

Sample code:

// PORTRAIT = 0, LANDSCAPE = 1, AUTO_ROTATE = 2(default) 
Bundle localExtras = new Bundle();
localExtras.putInt(VungleConstants.KEY_ORIENTATION, 2);
localExtras.putString(VungleConstants.KEY_USER_ID, "user id");

For rewarded ads, you will pass VungleAdapter.class on addNetworkExtrasBundle, while for interstitial ads, you will pass VungleInterstitial.class.

Sample code for loading waterfall rewarded ads:

AdRequest adRequest = new AdRequest.Builder()
        .addNetworkExtrasBundle(VungleAdapter.class, localExtras)
        .build();

RewardedAd.load(this, "AD_UNIT_ID", adRequest, new RewardedAdLoadCallback(){
    @Override
    public void onAdFailedToLoad(@NonNull LoadAdError loadAdError) { }

    @Override
    public void onAdLoaded(@NonNull RewardedAd rewardedAd) { }
});
    

Sample code for loading waterfall interstitial ads/banner ads:

AdRequest adRequest = new AdRequest.Builder()
        .addNetworkExtrasBundle(VungleInterstitialAdapter.class, localExtras)
        .build();
 
InterstitialAd.load(this, "AD_UNIT_ID", adRequest, new InterstitialAdLoadCallback() {
    @Override
    public void onAdLoaded(@NonNull InterstitialAd interstitialAd) { }
 
    @Override
    public void onAdFailedToLoad(@NonNull LoadAdError loadAdError) { }
});

Sample code for loading header bidding ads (all ad types, including native ad waterfall and header bidding):

AdRequest adRequest = new AdRequest.Builder()
        .addNetworkExtrasBundle(VungleMediationAdapter.class, localExtras)
        .build();

Android ID

Starting with Vungle Android SDK v.6.4.11, publishers can now restrict passing the Android ID from the device to the SDK.

Sample code:

VunglePrivacySettings.setPublishAndroidId(true);

Questions?

Need further assistance, feel free to reach out to us, we’re here to help!

Was this article helpful?