Google Admob Ads Implementation in Android using Kotlin | Admob Ads Kotlin | Android Studio | Kotlin

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey there everyone welcome to another video fox Android so in this video we're gonna learn how to implement admob ads to our Android application using calling as the backend language right so let me just demonstrate what we're going to get by the end of this video so if you can see on my mobile screen on this particular activity at the bottom you can see a banner ad right a nice Banner ad so I haven't implemented the actual ad IDs as it could lead to the illegal click ads right or The Impressions so for that sake I have implement the test ads but we're going to learn how to implement the actual ads right so here is this button if I just click on this button so basically this button was intended to go to the next activity but we got the interstitial ads in between so we just close this ad by typing on that cross button on the left upper corner right we go to the next activity so we're gonna learn how to implement these two ads Panerai and the inter special ads right so if you want to implement the same to your rendered application make sure you watch this video till the end so without Much Ado let's get started thank you so guys if you're new to this channel make sure to hit that subscribe button press the Bell notification icon for Sim notification of the upcoming videos and by the end of the video if you like the video make sure to hit that Thumbs Up Button as well so let's start with the development so the very first thing we are going to do is we are going to this URL right so here we are going to login with our admob account so if you have the account you just click on the sign in button and log into this add more account and in case you do not have the account you can just simply sign up right I have the account so I'll just sign in in that account I'll put the link for this website in the description below you can just check out that link as well so okay we have successfully logged into our admob account so here uh we need to tap on this apps button right so add app because we are going to create a new app for this admo mob account it is Android app so I'll just tap on this so right now I'm not going to list on the Play Store so click no continue will give it a app name I'll just type in test three add upright so that is all we have created an app to our admob account so done so we have got the ad so now we are going to create ad units so that we need to click on this add ad unit so the first ad unit we are going to create is the banner ad so for that we are going to select let me just name it as Banner you can give it a name according to your requirement just create ad unit right so we have got the add unit ID here so this is we'll be using this to our Android application click on done add another ad unit just click on this interstitial ad I'll just give it a name of enter create ad unit done we have got the ID for this app unit as well so click on done so we have created to add units right so now we are going to the official documentation of this Google admob Google admob documentation if I just search that so we go to this developers.google.com let's click on this Android button right I'll also put the link for this website as well you can directly check out that this link right so we are going here on this get started right so the very first thing is saying is we need to add this dependency right so let me just copy this we're going to our Android project build.gradle app level build.grader I'm gonna just paste it here and click on this sync now right so now it will just download these dependencies and add to our project so let's go back to this file so the second thing we are going to do is we need to add this metadata to our Android dot manifest file so let me just copy this and go to our Android project so we are going to open this Android dot manifest right so here we'll just paste this in here right so here we want to declare the idea of our app that we have just created so for that we'll go here and app overview okay in the app settings I guess so this is the app ID so we need to copy this app ID to our Android manifest file so as of now I'm not going to use this but you make sure that you put this ID there so for example for the testing purpose the Android has provided this particular ID so I'm going to copy this and paste it here right so the second thing we are going to do is we need to declare two permissions the very first one is internet permission and the second permission will be Access Network state right so these two permissions are required so we are done with the dependencies and we are done with the metadata to the Android manifest file light so let us just go to the main activity where we want to implement the banner ads so let me just go to the documentation and if I just tap on this Banner get started so basically there are two methods to implement this Banner ad you can add in the XML file as well or you can implement it programmatically but we are going to add in the XML so for that we need to copy this just copy this come here and paste it to the activity where you want to implement it right so you can see we have got this ad right so now we are going to the backend code for this so let me just go to the kotlin file so let's go back to this particular documentation so here to implement this we are going to implement this particular code right so let me just copy this first and paste it here and then we are going to copy let us create a method for this so let me create load and let me call this method inside oncreate and let us just create this method and inside this method we are going to copy the code from here and paste it here right so let us just implement this dependency just click here press Alt Enter and click on this import enter both and we are going to import this add request com.google.androidgms dot adds right done okay we need to implement this dependency as well I guess we have implemented it yeah so done so that is pretty much everything we need to do to implement the banner ads right so but still we are going to override certain methods so let me just show you that so just if I come here so you can see we need to attach a listener to the address this is completely optional it depends on you so let me just copy this as well and paste it here just click here put into click here Alt Enter import so what this code does is it'll just attach a listener to your this ad view right whenever a ad is loaded this particular method will be called right so code to be executed when the ad finish loading so let me just raise a toast so done for this tutorials like I've just erased the toast it's depend on your application what you want to do once the app is loaded right and on ad close so what will happen when the user clicks on that ad and comes back to the application by closing that particular URL that has been redirected to when the user clicks on the ad so what happens when the user come back to the ad so let us just raise a toast again and copy this and paste it here and let me write a returned to the app right so that is all we need to do to implement the banner ad so let me just quickly install this app and check if it is working fine or not I guess we are getting some error okay I have put in this extra packet let me delete this so let us just uh install the app and check if band ride is working fine or not right so okay guys the app has been installed to my cell phone if I just open this app here you can see the ad has loaded and we have got the toast as well right so let's just move to the uh interstitial ads now we have implemented the banner ads right so let's just move to the interstitial ads so for the interstitial ads let's go to the documentation again and just tap on this interstitial ads so for the interstitial as we need not to do anything to the front end part right we need to just implement it in the backend code only so okay I just forgot to tell you something here you can see that we have ADD unit ID so we have just used the sample add unit ID but in your case you are going to implement let me just add units for example for the banner ad you will be using this ID right for the ads you are implementing to your Android application right so let's go to the interstitial ads so first let us just copy this one this particular variable copy and go to the main activity and let us put it here right so we have declared this variable now let us just create a method load enter and write let's create this method so now inside this method first we are going to make the ad right so making the ad means that we are going to keep the interstitial add in our cache so before the user performs any action in which we want to show the in the social ad so before that we are going to create it so for that we'll just go here and here you can see we have to copy this particular code and paste inside this right so let's just lead this log because we do not need it and this is the sample add unit ID right so in case you are just testing your app you can keep this ad unit ID but if you want to make your app live or deploy your app to the Play Store right then you have to replace it with the actual add unit ID right so we have made the ad here so now after that let us just uh refer to the button that we have made in the activity on which the user clicks and we want to show the interstitial ad so let me just uh call it as enter add button and the type of which will be button only and let us refer it by using find view by ID r dot ID dot enter ads right so now we are going to set the on click listener on this internet Dot set on click listener so inside this we we are going to show the interstitial ad so let us create a method show enter ad and let's just create this function so inside this function we are going to make the ad visible so for that first we are going to check that if this is not equal to null right this should not be equal to null because we have a referred to the interstitial ad using this variable so if M interstitial add is not equal to null we are going to show the ad but else if for some reason this points to null that means we are unable to make the interstitial add then we do not want to spoil the user experience we will perform the action that was intended to make by that particular button or anything on which you are applying this interstitial ads right so for in my case I want to move to the next activity so I'll create a intent for that and start the next activity right and start activity and will pass the intent here but in case the interstitial ad has been successfully loaded then we are going to call M interstitial ad Dot full screen content callback and will pass the object of this class and now we are going to overwrite certain methods so just click here on the object right click generate override methods so let us just override all these methods it's completely option and up to you if you want to override these methods right but you have to overwrite this particular method on ADD dismissed full screen content right so this particular method will be called when the user closes the interstitial layer right when we tap on that cross button this callback method will be called so inside this we are going to call this method only this particular action right okay we have to because it's inside the another class so we have to make it like this right so on ADD inflation will be called when there is a successful impression of the ad that means when the ad opens up right so this will also be called on ADD showed full screen content and in case on ADD fail to show full screen content then you can perform some action here right it totally depends on the application of your app right so you can make the or manipulate these functions in your own way so right now I'm just overriding this particular method on a dismissed full screen content so I am going to the next activity right so that is pretty much everything we need to do and one more thing now we are going to show this ad so for that we are going to call m in the social ad dot show and we need to pass the context of this activity and let's just put normal session so that is all we need to do so let me just quickly install this app to my cell phone and check if it is working fine or not right so here is the app has been installed to my cell phone as you can see on my mobile screen if I just tap on this button the interstitial ad is shown on the screen if I just close the set by tapping on this cross button we move to the second activity right so I guess we have successfully implemented this feature to our Android application and I also hope that you guys have understood the code in case of any doubt you can always ask me in the comment section or you can DM me on Instagram the Instagram username will be there on the screen right now if you like the video don't forget to hit that thumbs up button and in case you're new to this channel make sure to hit that subscribe button press the Bell notification icon for soon notification of the upcoming videos so that is it for today's video see you another video bye [Music] thank you [Music]
Info
Channel: Foxandroid
Views: 1,342
Rating: undefined out of 5
Keywords: android admob, how to use admob in android, admob ads, android studio, admob, using admob in android, ads in android studio, ads in android app, admob android studio tutorial, how to add ads in android app, banner ad in android, admob ads in android, ad in android studio, admob android studio 2020, how to implement admob ads in android studio, admob ads implementation, admob banner ad implementation, how to place admob ads, android admob tutorial 2021, kotlin, admob kotlin, 2023
Id: NaKhsZTQP8s
Channel Id: undefined
Length: 17min 55sec (1075 seconds)
Published: Sun Jul 09 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.