Google Admob Banner vs Interstitial advertisements
Banners Ads are small advertisements that are normally displayed on the prime or backside of the display screen as proven int the determine beneath. Standard android admob banner measurement is 320×50 though different sizes are additionally obtainable. Banner Ads are extremely popular with cell builders since they don’t intrude a lot with the consumer expertise and cowl very small a part of the display screen. However they’ve a low engagement charges.
Interstitials Ads are larger full-screen advertisements. They block the display screen for a while till the consumer presses a “x” button to shut the Ad. By blocking the whole display screen interstitial Ads compel the consumer to work together with the advert, giving excessive consumer engagement and conversion charges. However these Ads if not added at correct locations will typically lead to irritating consumer expertise. Below is an instance of interstitial advert.
In this tutorial, we’ll focus on Google admob integration on Android utilizing an instance App. We might be making a dummy sport app consisting of two ranges. Level One will present the Banner Ads and when the consumer clicks on the LevelTwo an Interstitial Ad might be loaded and the consumer might be taken to Level Two as soon as the Ad is closed.
Before beginning the dialogue, please notice the next:
Creating a New Android Studio Project
This will create new android studio challenge. Now you might be prepared to montetize your new Game App.
Create your Ad Units
Add Banner and Interstitial provides to your Project
Replace the ad_id_interstitial and ad_id_banner with your individual Ad ID’s, we now have additionally added another string sources which might be used within the challenge later.
Next, add the google play companies meta knowledge to the appliance tag. This embeds the model of Google Play companies that the app was compiled with.
Also add an Ad exercise to deal with the config modifications of your app like orientation change.
Completed AndroidManifest.xml code might be as within the following file => AndroidManifest.xml
Here we’re utilizing a Relative Layout as a father or mother format. We have a TextView to show a static message “My Game App”, Next we now have a TextView to show the present stage of the sport. We solely have two Levels – Level One and Level Two.
Then we now have a button that can take us to Level Two. In the tip, we now have a Google Admob Adview which might be used to show the Banner Ads on the backside of your app Screen as mentioned in beginning. We have added the advertUnitId for the banner Ad utilizing our ad_id_banner string useful resource. For Banner Ads adSize has a price of Banner.
In the onCreate() technique of LevelOneExercise intialize add the reference to the buttons and views. Also add an OnClickListener() for the Level Two Button and explicitly allow it on begin of the exercise.
Next, Create and Load a brand new Interstitial Ad and then load Banner Ads. For now simply put the next strategies in onCreate() technique of the LevelOneExercise.java, we might be explaining these strategies subsequent.
The presentBannerAd() technique builds a brand new adRequest utilizing the AdRequest.Builder() technique and then the request is loaded to the Banner AdView we added to the format File, Please notice using addTestDevice(“754DB6521943676637AE86202C5ACE52”) technique within the technique. As we now have mentioned at first the app developer mustn’t click on on his personal reside advertisements. To stop your Admob account from being suspended you must all the time work with the check advertisements. When you run the LogCat output will present you the TestDeviceId to your system as proven within the determine beneath.
Add the next strategies after onCreate() technique of the LevelOneExercise.java.
Also add createNewIntAd() technique after the presentBannerAd(), This technique creates a brand new Interstitial Ad and additionally units the AdUnitId and setAdListener property of the brand new Interstitial Ad. In the AdListener we now have are enabling the LevelTwoButon as soon as the Ad is loaded and additionally within the case that Ad fails to load. Once the consumer closes the Ad the Game proceeds to stage two by calling the operate stageTwo() .
Next, Add the next code in LevelOneExercise after the above strategies. The presentIntAdd() checks whether or not the add has been loaded and whether it is obtainable then it shows the Ad in any other case it shows the subsequent stage of the sport. The loadIntAdd() will disable the extent two button and then create a brand new adRequest comparable to presentBannerAd() technique and then hundreds the request within the AdView. The stageTwo() invokes the second stage of our sport, right here we’re simply making the button disappear and altering the extent textual content to show Level Two.
On completion the LevelOneExercise.java code might be as within the following file => LevelOneActivity.java
Now, run the app in your cellphone or emulator and you must see Banner Ad on the backside of the display screen and Interstitial Ad on clicking Level Two Button.
You can create an awesome Android app, combine the Google Admob SDK and put it on Google Play Store to begin incomes instantly. Soon we might be protecting how to add your apps to Google Play Store. Till then keep tuned for extra tutorials.. and Don’t overlook to subscribe our weblog for contemporary android tutorials. Also do Like our Facebook Page or Add us on Twitter.
Click on the Download Now button to obtain the total code.