Android AdMob

30% OFF - 9th Anniversary discount on Entity Framework Extensions until December 15 with code: ZZZANNIVERSARY9

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?