Interstitial Ads Integration For Android english - Hiroaki-Shinoda/Geniee-Android-SDK GitHub Wiki
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.
To implement the banner ads, you need to install Geniee SDK to the project. Please follow the Start Guide for the process. Start Guide
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
-
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;
-
Implement
GNInterstitialListener
andGNInterstitialDialogListener
interfacepublic class GenieeSampleBanner extends Activity implements GNInterstitialListener, GNInterstitialDialogListener { }
-
Declare the variable of
GNInterstitial
GNInterstitial interstitial = null;
-
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.
-
Set the implementation class of
GNInterstitialListener
interface
For interstitial ads load event, you will be notified via the interface implementation class.
SetGNInterstitialListener
interface implementation variables.interstitial.setListener(this);
-
Set the implementation class of
GNInterstitialDialogListener
interface
For Interstitial ads load event, you will be notified via the interface implementation class.
SetGNInterstitialDialogListener
interface implementation variables.interstitial.setDialoglistener(this);
-
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);
}
} ```
AdSize of 300x250.
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 GNInterstitialListener
onReceiveSetting()
CallBack function of delegate. -
If it fail to load, it will be notified by GNInterstitialListener
onFailedToReceiveSetting()
CallBack function of delegate.- API loaded
public void load(Activity activity)
- Example for API loaded
interstitial.load(this);
- Parameter
this
:Current screen of Activity variable
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); }
- Parameter
this
:Current screen of Activity variable
To update the interstitial ads, you will need to display to load ad again.
-
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(); }
-
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); }