Android AdMob

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Syntax

  • compile 'com.google.firebase:firebase-ads:10.2.1' //NOTE: SET TO NEWEST VERSION IF AVAILABLE
  • <uses-permission android:name="android.permission.INTERNET" /> Required to retrieve the ad
  • AdRequest adRequest = new AdRequest.Builder().build();//Banner ad
  • AdView mAdView = (AdView) findViewById(R.id.adView);//Banner ad
  • mAdView.loadAd(adRequest);//Banner ad

Parameters

ParamDetails
ads:adUnitId="@string/main_screen_ad"The ID of your ad. Get your ID from the admob site. "While it's not a requirement, storing your ad unit ID values in a resource file is a good practice. As your app grows and your ad publishing needs mature, it may be necessary to change the ID values. If you keep them in a resource file, you never have to search through your code looking for them.".[1]

Remarks

  • Requires a valid Admob account
  • Read the admob policy. Make sure you do not do anything that can get your admob account suspended


Got any Android Question?