Many developers use AdMob as their primary app monetization network, AdMob offers full screen ads called interstitial ads that cover the entire screen, usually they are displayed at natural transition points in the flow an app. The ad will appear in transition of one activity to another. Your app is required to load interstitial ad asynchronously. When we compare to other app monetization networks, AdMob has very strict policy against invalid clicks so make sure that your app has no tendency to generate invalid action (ad appears closely to UI, own clicks etc) if so your AdMob account will disable soon. The tutorial explains how to integrate AdMob interstitial ad into your Android app.
Before begin with AdMob interstitial ad
It is important to understand the flow of your app, when choose AdMob interstitial ad. Is your app capable of showing interstitial ad? If your app does not have proper ending point consider banner ad instead of intestinal ad.It's important to make sure that your app displays test ads before production.
Setting up Google play services
Android Studio Users
1. Open build.gradle file
2. Add a new build rule like below
apply plugin: 'com.android.application' ... dependencies { compile 'com.google.android.gms:play-services:7.x.x' }
InterstitialAd interAd;
interAd=new InterstitialAd(this);
if (interAd.isLoaded()) {
interAd.show();
}
Putting all together
package com.bigknol.myad; import android.app.Activity; import android.content.ActivityNotFoundException; import android.os.Bundle; import android.view.View; import android.view.Window; import android.widget.Button; import android.widget.Toast; import com.google.android.gms.ads.AdListener; import com.google.android.gms.ads.AdRequest; import com.google.android.gms.ads.InterstitialAd; public class InterAdTest extends Activity { Button startLesson; private InterstitialAd interAd; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_content); startLesson = (Button) findViewById(R.id.writing_advanced); /******** Interstitial Ad implementation ************/ interAd = new InterstitialAd(this); interAd.setAdUnitId(getString(R.string.ad_unit_interstitial)); //ad unit id will be saved as a string /**********/ interAd.setAdListener(new AdListener() { @Override public void onAdClosed() { requestNewInterstitial(); } }); requestNewInterstitial(); startLesson.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub /********/ if (interAd != null && interAd.isLoaded()) { interAd.show(); } else { } /********/ } }); } @Override public void onPause() { super.onPause(); } @Override public void onResume() { super.onResume(); } @Override public void onDestroy() { super.onDestroy(); } /**** Interstitial menhod ****/ private void requestNewInterstitial() { AdRequest adRequest = new AdRequest.Builder() .addTestDevice("00XXXXXXXXX") //put your device id .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) //test ad will appear in emulator .build(); interAd.loadAd(adRequest); } /*******/ }
Recommended Tool
Integrate Google Analytics v4 into android app
for acquiring demographic and ad impression info quickly. You can easily figure
out your revenue flow with Google Analytics. Head
over to analytics where you can get accurate statistics about your app.
AdMob Interstitial Ads Android Integration
Reviewed by Nikin
on
15 January
Rating: