Android Displaying Google Ads edit

Basic Ad Setup

You’ll need to add the following to your dependencies:

compile 'com.google.firebase:firebase-ads:10.2.1'

and then put this in the same file.

apply plugin: 'com.google.gms.google-services'

Next you’ll need to add relevant information into your strings.xml.

<string name="banner_ad_unit_id">ca-app-pub-####/####</string>

Next place an adview wherever you want it and style it just like any other view.

<com.google.android.gms.ads.AdView
    android:id="@+id/adView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_alignParentBottom="true"
    ads:adSize="BANNER"
    ads:adUnitId="@string/banner_ad_unit_id">
</com.google.android.gms.ads.AdView>

And last but not least, throw this in your onCreate.

MobileAds.initialize(getApplicationContext(), "ca-app-pub-YOUR_ID");
AdView mAdView = (AdView) findViewById(R.id.adView);
    AdRequest adRequest = new AdRequest.Builder().build();
    mAdView.loadAd(adRequest);

If you copy-pasted exactly you should now have a small banner ad. Simply place more AdViews wherever you need them for more.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


Table Of Contents
39 ACRA
64 Menu
112 Loader
119 Xposed
132 Colors
135 Fresco
140 AdMob
147 Button
155 Displaying Google Ads
156 Vk SDK
170 XMPP
176 OpenCV
200 FileIO
203 Moshi
217 Paint
231 AIDL
241 JCodec
243 Okio
255 Looper
  ↑ ↓ to navigate     ↵ to select     Esc to close