AdMob

Download android eBook

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

Related Examples

Stats

57 Contributors: 6
Monday, August 7, 2017
Licensed under: CC-BY-SA

Not affiliated with Stack Overflow
Rip Tutorial: info@zzzprojects.com

Download eBook