Interstitial Ads Integration For Android English - Hiroaki-Shinoda/Geniee-Android-SDK GitHub Wiki

Implementation of Interstitial Ads

Interstitial ads are full-screen advertising that cover the interface of the host app. The ads are typically displayed at natural transition points in the flow of an app, such as start-up the application, or between activities or during the pause between levels in a game.

Preparation

To implement the banner ads, you need to install Geniee SDK to the project. Please follow the Start Guide for the process. Start Guide

Class and Interface

Android interstitial ad delivery use the following class.

  • GNInterstitial Asynchronous acquisition interstitial Ads, Class for Display
  • GNInterstitialListener Ad load event processing interface
  • GNInterstitialDialogListener Ad click event processing interface

Set Up Interstitial Ads

  1. Import GNInterstitial

    import jp.co.geniee.gnadsdk.interstitial.GNInterstitial;
    import jp.co.geniee.gnadsdk.interstitial.GNInterstitial.GNInterstitialListener;
    import jp.co.geniee.gnadsdk.interstitial.GNInterstitial.GNInterstitialDialogListener;
    import jp.co.geniee.gnadsdk.common.GNAdLogger;
  2. Implement GNInterstitialListener and GNInterstitialDialogListener interface

    public class GenieeSampleBanner extends Activity implements GNInterstitialListener, GNInterstitialDialogListener
    {
    }
  3. Declare the variable of GNInterstitial

    GNInterstitial interstitial = null;
  4. Initializes the instance of GNInterstitial

  • API initialized
    public GNInterstitial(Context context, int appid)
  • Example for using of API initialized
    interstitial = new GNInterstitial(this, YOUR_SSP_APP_ID);

thisParameter sets Context of App.
YOUR_SSP_APP_ID sets management ID of AdsZone in Geniee.

  1. Set the implementation class of GNInterstitialListener interface
    For interstitial ads load event, you will be notified via the interface implementation class.
    Set GNInterstitialListener interface implementation variables.

    interstitial.setListener(this);
  2. Set the implementation class of GNInterstitialDialogListener interface
    For Interstitial ads load event, you will be notified via the interface implementation class.
    Set GNInterstitialDialogListener interface implementation variables.

    interstitial.setDialoglistener(this);
  3. Set default HTML screen. (Optional)
    If you can not connect to the Internet please implement :

    String strHtml = "<html>...Your_Default_Html_Content...</html>";
    interstitial.setDefaultHtml(strHtml);
  • Example Implementation of GNAdSampleInterstitial:
    import jp.co.geniee.gnadsdk.interstitial.GNInterstitial;
    import jp.co.geniee.gnadsdk.interstitial.GNInterstitial.GNInterstitialListener;
    import jp.co.geniee.gnadsdk.interstitial.GNInterstitial.GNInterstitialDialogListener;
    import jp.co.geniee.gnadsdk.common.GNAdLogger;

public class GNAdSampleInterstitial extends ActionBarActivity implements GNInterstitialListener, GNInterstitialDialogListener { private GNInterstitial interstitial = null;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_gnad_sample_interstitial);

    // Initializes a GNInterstitial
    interstitial = new GNInterstitial(this, YOUR_SSP_APP_ID);
    interstitial.setListener(this);
    interstitial.setDialoglistener(this);
    //interstitial.setGeoLocationEnable(true);
    //interstitial.setLogPriority(GNAdLogger.INFO);
}

} ```

Size of Interstitial Ads

AdSize of 300x250.

Interstitial ads load

Load interstitial ad display tags from Ad server.
GNInterstitial is preloaded before display,
it is recommended that you set the appropriate time to prepare for completion ad.

  • If it success to load, it will be notified by GNInterstitialListeneronReceiveSetting() CallBack function of delegate.

  • If it fail to load, it will be notified by GNInterstitialListeneronFailedToReceiveSetting() CallBack function of delegate.

    • API loaded
    public void load(Activity activity)
    • Example for API loaded
    interstitial.load(this);
    • Parameterthis:Current screen of Activity variable

Display Interstitial Ads

Please check the display interstitial ads before delivering

  • Example interstitial display at the time of screen transition.

    • API display
    public boolean isReady()
    public boolean show(Activity activity)
    • Example API display
    if(interstitial.isReady()) {
        interstitial.show(this);
    }
    • Parameterthis:Current screen of Activity variable

Update of interstitial ads

To update the interstitial ads, you will need to display to load ad again.

GNInterstitialListener interface

  • Implement CallBack function of GNInterstitialListener, you will receive ad load event.

    public static abstract interface GNInterstitialListener
    {
        // It will be sent when reading of the advertising data has been completed.  
        public abstract void onReceiveSetting();
        
        // It will be sent to when that failed to read ad in the cause such as a network error.  
        public abstract void onFailedToReceiveSetting();
    }

GNInterstitialDialogListener interface

  • You will receive the ad click after implementing CallBack function of GNInterstitialDialogListener .

    public static abstract interface GNInterstitialDialogListener
    {
        // It will be sent immediately after the interstitial ad screen is closed.  
        public abstract void onClose();
        
        // From the management screen, buttons that were installed in the advertising screen is tapped,  
        // It will be sent immediately after the interstitial ad screen is closed.  
        // Number of buttons that have been tapped, you will be notified by `nButtonIndex` parameter.  
        public abstract void onButtonClick(int nButtonIndex);
    }
⚠️ **GitHub.com Fallback** ⚠️