Implementation of AdMob/AdManager fullscreen interstitial mediation

By using mediation function of AdMob/AdManager, it can distribute fullscreen interstitial of Geniee SDK from AdMob/AdManager.

Preparation for implementation

For Fullscreen Interstitial Advertisement, the following implementation preparation is necessary.

  • Google Play Services SDK To use the Geniee ad SDK, you must install the Google Play Services SDK. The Google Play Services SDK installation procedure is as follows.
  1. Add the following to dependencies ofModule> build.gradle.
dependencies {
    implementation 'com.google.android.gms:play-services-ads:20.0.0'
}
  • If you have already installed the Google Play Services SDK, no addition is required.

  • Geniee SDK

    From the start guide below, you need to install Geniee SDK (GNAdSDK) in the application.
    Start Guide

  • AndroidManifest.xml

    Please set the following permissions to AndroidManifest.xml.

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    
    1
    2
    3
    4
    5
    6
  • SDK for each add network and adapters

    It is necessary to set the SDK for each ad network and the adapter to distribute using Mediation function of AdMob/AdManager and Geniee SDK.
    To set all the ad networks collectively, please refer to the following link introduction method.
    Bulk Implementation of All Ad Networks

    Also, in order to use the ad network individually, please select the ad network link from the following and refer to the introduction method.

    Ad Network Verified version
    maio 1.1.13
    AppLovin 9.14.5
    Nend 5.4.2
    Zucks 4.7.0
    Tapjoy 12.7.0
    UnityAds 3.4.8
    Vungle 6.8.0
    Imobile 2.0.20

Implementation of SDK for AdMob/AdManager Interstitial Mediation

  1. Add the following to allprojects> repositories inProject> build.gradle.

    allprojects {
        repositories {
            // GenieeSDK
            maven { 
                url 'https://raw.github.com/geniee-ssp/Geniee-Android-SDK/master/repository' 
            }
        }
    }
    
    1
    2
    3
    4
    5
    6
    7
    8
  2. Add the following to dependencies ofModule> build.gradle.

     dependencies {
         implementation 'jp.co.geniee.gnadgooglemediationadapter:GNAdGoogleMediationAdapter:8.5.0.0'
     }
     
  3. Implementation example

  • Project>build.gradle

    allprojects {
        repositories {
            jcenter()
            google()            
            // GenieeSDK
            maven { 
                url 'https://raw.github.com/geniee-ssp/Geniee-Android-SDK/master/repository'
            }
            // nendSDK
            maven {
                url 'http://fan-adn.github.io/nendSDK-Android-lib/library'
            }
            // Maio SDK
            maven{
                url "https://imobile-maio.github.io/maven"
            }
            // ZucksSDK
            maven {
                url 'https://github.com/zucks/ZucksAdNetworkSDK-Maven/raw/master/'
            }
            // Tapjoy SDK
            maven {
                url "https://tapjoy.bintray.com/maven"
            }
        }
    }
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
  • Module>build.gradle

      dependencies {	
          implementation fileTree(include: ['*.jar'], dir: 'libs')
          // Google SDK
          implementation 'com.android.support:appcompat-v7:26.1.0'
          implementation 'com.android.support.constraint:constraint-layout:1.1.1'
          implementation 'com.google.android.gms:play-services-ads-identifier:17.0.0'
          // Geniee
          implementation 'jp.co.geniee.gnadsdk:GNAdSDK:8.5.1' // GenieeSDK
          implementation 'jp.co.geniee.gnadgooglemediationadapter:GNAdGoogleMediationAdapter:8.5.0.0'
          // Nend
          implementation 'com.android.support:cardview-v7:26.1.0'
          // Vungle Optional Google Play Services
          implementation 'com.google.android.gms:play-services-location:15.0.1'
      }
      

Introduce libraries manually

If it followed the Installing libraries with Maven procedure, you do not need to do this step.

Manual introduction procedure here

Download Geniee Adapter SDK

Download Geniee Android SDK from the following URL.

Placing the Local Library

  1. Extract Geniee Android SDK.

  2. Add GNSFullscreenInterstitialAdapter to the project.

  • If the libs folder does not exist, create it as necessary.

  • Copy the following files under the GNAdGoogleMediationAdapter folder to thelibs folder.
    - GNAdGoogleMediationAdapter-8.5.0.0.jar

  • Add to dependencies ofModule / build.gradle.

    dependencies {
        implementation fileTree(include: ['*.jar'], dir: 'libs')
    }
    
    1
    2
    3

Implementation of AdMob/AdManager interstitial advertisement

You can mediate AdMob/AdManager by calling it with the UnitID of the video rewinding mediated in AdMob/AdManager's management screen.
For details on how to implement AdMob/AdManager fullscreen interstitial, please refer to the following site.
https://developers.google.com/ad-manager/mobile-ads-sdk/android/interstitial

※ Implementation notes when using mediation

When creating the interstitial instantance, specify Activity instead of Context.
If you specify Context, mediation may not work.

Correspondence when the AdMob/AdManager interstitial ad becomes No fill

If AdMob/AdManager's interstitial fails to load, you can prevent the vacancy of ads by calling Geniee SDK. The implementation procedure is as follows.

  1. Import the neccesary classes of Geniee SDK and AdMob SDK.

    import com.google.android.gms.ads.AdError;
    import com.google.android.gms.ads.AdRequest;
    import com.google.android.gms.ads.FullScreenContentCallback;
    import com.google.android.gms.ads.LoadAdError;
    import com.google.android.gms.ads.interstitial.InterstitialAd;
    import com.google.android.gms.ads.interstitial.InterstitialAdLoadCallback;
    
    import jp.co.geniee.gnadsdk.fullscreeninterstitial.GNSFullscreenInterstitialAd;
    
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
  2. Create an instance of GNSFullscreenInterstitialAd in Geniee SDK by specifyingZoneID and initialize AdMob InterstitialAd

    // Declare AdMob Interstitial
    private InterstitialAd mInterstitialAd;
    // Delare Geniee Interstitial
    private GNSFullscreenInterstitialAd mGNSFullscreenInterstitialAd;
    
    
    // Geniee Interstitial
    mGNSFullscreenInterstitialAd = new GNSFullscreenInterstitialAd("YOUR_ZONE_ID", this);
    
    // AdMob/AdManager
    AdRequest adRequest = new AdRequest.Builder().build();
    InterstitialAd.load(this, "YOUR_AD_UNIT_ID", adRequest, new InterstitialAdLoadCallback() {
        @Override
        public void onAdLoaded(@NonNull InterstitialAd interstitialAd) {
            // The mInterstitialAd reference will be null until
            // an ad is loaded.
            mInterstitialAd = interstitialAd;
            mInterstitialAd.setFullScreenContentCallback(mFullScreenContentCallback);
    
            Log.i(TAG, "onAdLoaded");
        }
    
        @Override
        public void onAdFailedToLoad(@NonNull LoadAdError loadAdError) {
            // Handle the error
            Log.i(TAG, loadAdError.getMessage());
            mInterstitialAd = null;
    
            //Geniee SDK Load
            if (mGNSFullscreenInterstitialAd != null) {
                mGNSFullscreenInterstitialAd.loadRequest();
            }
        }
    });
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
  3. Implement the Geniee SDK GNSFullscreenInterstitialAdListener interface.

    mGNSFullscreenInterstitialAd.setFullscreenInterstitialAdListener(new GNSFullscreenInterstitialAdListener() {
       @Override
       public void fullscreenInterstitialAdDidReceiveAd() {
           Log.i("GNSFullscreen", "Fullscreen interstitial loaded.");
       }
       @Override
       public void fullscreenInterstitialAdWillPresentScreen(String adName) {
           Log.i("GNSFullscreen", "Fullscreen interstitial present.(" + adName + ")");
       }
       @Override
       public void fullscreenInterstitialAdDidClose(String adName) {
           Log.i("GNSFullscreen", "Fullscreen interstitial has been closed(" + adName + ")");
       }
       @Override
       public void didFailToLoadWithError(GNSException e) {
           Log.i("GNSFullscreen", "Fullscreen interstitial load failed。(" + e.getAdnetworkName() +
            " Code:" + e.getCode() + " " +
             e.getMessage());
       }
    });
    
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
  4. Implement the AdMob/AdManager SDK FullScreenContentCallback

    final FullScreenContentCallback mFullScreenContentCallback = new FullScreenContentCallback() {
        @Override
        public void onAdShowedFullScreenContent() {
            // Called when ad is shown.
            Log.d(TAG, "Ad was shown.");
            mInterstitialAd = null;
        }
    
        @Override
        public void onAdFailedToShowFullScreenContent(AdError adError) {
            // Called when ad fails to show.
            Log.d(TAG, "Ad failed to show.");
        }
    
        @Override
        public void onAdDismissedFullScreenContent() {
            // Called when ad is dismissed.
            // Don't forget to set the ad reference to null so you
            // don't show the ad a second time.
            Log.d(TAG, "Ad was dismissed.");
        }
    };
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
  5. Implement the loadRequest method of the Geniee SDK RewardVideo on the methodonAdFailedToLoadwhich is invoked if AdMob/AdManager Load fails.

    @Override
    public void onAdFailedToLoad(@NonNull LoadAdError loadAdError) {
        // Handle the error
        Log.i(TAG, loadAdError.getMessage());
        mInterstitialAd = null;
    
        //Geniee SDK Load
        if (mGNSFullscreenInterstitialAd != null) {
            mGNSFullscreenInterstitialAd.loadRequest();
        }
    }
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    • If you want to show another interstitial after presented one ad, you need to make a load request again.
  6. Check that loadAd / loadRequest is completed in the order of AdMob/AdManager → Geniee SDK and display the FullscreenInterstitial by show method.

    if (mInterstitialAd != null) {
        mInterstitialAd.show(this);
    } else if (mGNSFullscreenInterstitialAd != null && mGNSFullscreenInterstitialAd.canShow()) {
        mGNSFullscreenInterstitialAd.show();
    }   
    
    1
    2
    3
    4
    5
    • Please be sure to execute show after loading AdMob/AdManager.
  7. We will attach the activity life cycle to mGNSFullscreenInterstitialAd. This is used to control stop and restart of advertisements.

     @Override
    protected void onStart() {
        super.onStart();
        if (mGNSFullscreenInterstitialAd != null) {
            mGNSFullscreenInterstitialAd.onStart();
        }
    }
    
    @Override
    protected void onResume() {
        super.onResume();
        if (mGNSFullscreenInterstitialAd != null) {
            mGNSFullscreenInterstitialAd.onResume();
        }
    }
    
    @Override
    protected void onPause() {
        if (mGNSFullscreenInterstitialAd != null) {
            mGNSFullscreenInterstitialAd.onPause();
        }
        super.onPause();
    }
    
    @Override
    protected void onStop() {
        if (mGNSFullscreenInterstitialAd != null) {
            mGNSFullscreenInterstitialAd.onStop();
        }
        super.onStop();
    }
    
    
    @Override
    protected void onDestroy() {
        if (mGNSFullscreenInterstitialAd != null) {
            mGNSFullscreenInterstitialAd.onDestroy();
        }
        super.onDestroy();
    }
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
  • Also be sure to link AdMob/AdManager life cycle events.
  • When using interstitial for the whole application Please exclude the implementation of mInterstitialAd.onDestroy(). If you implement mInterstitialAd.onDestroy() the data of interstitial will be destroyed.
Last Updated: 5/12/2021, 3:26:10 PM