Make Money Online BANNERS How to set AdMob Banner In Navigation Drawer | Implementing AdMob Banner Ad In Navigation Drawer

How to set AdMob Banner In Navigation Drawer | Implementing AdMob Banner Ad In Navigation Drawer

How to set AdMob Banner In Navigation Drawer | Implementing AdMob Banner Ad In Navigation Drawer post thumbnail image


Nowadays, AdMob is one of the best and most popular mobile advertising platforms. It provides developers with an easy way to monetize their apps by displaying ads to users. AdMob is available for Android, iOS, and Unity platforms. In this article, we will focus on how to set AdMob banner in navigation drawer.

First of all, let’s create a new project in Android Studio. Choose the “Navigation Drawer Activity” template while creating a new project. Then open the “app/build.gradle” file and add the following dependency in the “dependencies” section:

implementation ‘com.google.android.gms:play-services-ads:18.3.0’

After that, open the “activity_main_drawer” layout file and add the following code inside the “LinearLayout” with id “@+id/container”:

Now open the “MainActivity.java” file and add the following code inside the “onCreate” method:

MobileAds.initialize(this, ““); // Replace with your App ID from AdMob console

AdView adView = findViewById(R.id.adView);
adView.loadAd(new AdRequest .Builder().build());

In the above code, we are initializing Mobile Ads SDK with our App ID and then loading a banner ad using AdRequest class . Finally, we are adding the banner ad to our navigation drawer layout . You can also use other methods of Ads class like loadBannerAd(String) or loadInterstitialAd(String) . For more information, please check out this link https://developers.google.com/admob/android/banner . That’s it! Now run your app and see if everything works as expected

Related Post