The video above shows you the steps to integrate the Interestitial Ads in an Android app.
Interstitial ads are full screen ads that cover the interface of the app until closed by the end user. Naturally, it is best to show them when there is any pause in the flow of an app’s execution, like for example: the between levels in a game, or simply, just after a task was completed.
In this tutorial we will apply and integrate the Interstitial ads in an Android App made using Java programming language.
First of all you import and implement the repositories in Gradle:
implementation 'com.google.android.gms:play-services-ads:19.0.0'
After, you’ve add it, synchronize all the repositories.
Then, we need to update the AndroidManifest.xml file, by adding the ad meta-data.
To do that, add the code below to your AndroidManifest.xml file:
<!-- Sample AdMob App ID: ca-app-pub-3940256099942544~3347511713 --> <meta-data android:name="com.google.android.gms.ads.APPLICATION_ID" android:value="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy"/>
Remember, the code above needs to go within/inside the <application> tags of your manifest, in my case it goes after the </activity> tag.
Always, when you test, use the test ad ids provided by Google. Never, use your production ads for testing purposes, as you might get banned.
Next step, is to declare your add variable in the MainActivity.java.
private InterstitialAd mInterstitialAd;
The other steps to follow are to then initialize the interstitial ads, define the layout in the app front-end and test if the test Interstitial ads will be shown.
Then, lastly you can implement the other events related to the Interstitial Ads, like the onAdClosed(), onAdClicked() and other events.
To learn more, check the links below:
- https://developers.google.com/admob/android/quick-start
- https://developers.google.com/admob/android/interstitial
When you are all set with the app, have done the testing and you are ready to deploy it to the Google App platform, don’t forget to replace your production ad id with your test id.
If you want to learn how to setup the banner ads in your Android App, check the following link: How To Add AdMob Ads in Android App – Banner Ads
Hope, this was useful.
Leave you comments in the section below!