Android application display Interstitial Ads tutorial

The preparation for coding

Before reading this tutorial, please read the getting startted with android ads to learn how to get library, how to install AD library, how to add configuration information

Add advertising related Java code

1.The first import keymob related classes
    import com.keymob.networks.AdManager;
    import com.keymob.networks.core.*;
import com.keymob.sdk.core.AdTypes;
2.Initialization Keymob
Initialization Keymob library management is the prerequisite to call other advertising functions , the following is to init with the Keymob.com service
AdManager.getInstance().initFromKeymobService(this, "1", new AdEventListener(), false);
3. Loading ads
AdManager.getInstance().loadInterstitial();
4.Check whether advertising load successfully
AdManager.getInstance().isInterstitialReady();
5.Display advertising
AdManager.getInstance().showInterstitial();
6.Android display Interstitial advertising
Display ads before loading, the following style is a well way
   if(AdManager.getInstance().isInterstitialReady()){
		AdManager.getInstance().showInterstitial();
	}
7. Monitor advertising events
In Interstitial advertising can show at the end of the game or show it manual ,or can be shown when loaded
    	class AdEventListener implements IAdEventListener {
		@Override
		public void onLoadedSuccess(int arg0, Object arg1,
				PlatformAdapter arg2) {
			Log.d(TAG, arg2+" onLoadedSuccess for type "+arg0 +" withdata "+arg1);
			if(arg0==AdTypes.INTERSTITIAL){
				((IInterstitialPlatform)arg2).showInterstitial();//show ad when load success 
			}
		}

		@Override
		public void onLoadedFail(int arg0, Object arg1, PlatformAdapter arg2) {
			Log.d(TAG, arg2+" onLoadedFail for type "+arg0 +" withdata "+arg1);
		}

		@Override
		public void onAdOpened(int arg0, Object arg1, PlatformAdapter arg2) {
			Log.d(TAG, arg2+" onAdOpened for type "+arg0 +" withdata "+arg1);
		}

		@Override
		public void onAdClosed(int arg0, Object arg1, PlatformAdapter arg2) {
			Log.d(TAG, arg2+" onAdClosed for type "+arg0 +" withdata "+arg1);
		}

		@Override
		public void onAdClicked(int arg0, Object arg1, PlatformAdapter arg2) {
			Log.d(TAG, arg2+" onAdClicked for type "+arg0 +" withdata "+arg1);
		}

		@Override
		public void onOtherEvent(String eventName, int adtype, Object data,
				PlatformAdapter adapter) {
			Log.d(TAG, adapter+" onLoadedSuccess for type"+adtype +" withEvent "+eventName);
		}
	}

Configuration changes

After writing the code, in accordance with the previous tutorial, add permissions configuration and Activity configuration information

More tutorial of add ad in app   qq group 310513042   home