STEP 4: JAVA SOURCE You should see some errors on source code. First replace imports import com.google.ads.AdRequest; import com.google.ads.AdSize; import com.google.ads.AdView; with import com.google.android.gms.ads.AdRequest; import com.google.android.gms.ads.AdSize; import com.google.android.gms.ads.AdView; Add the following line to manage ads layout import android.widget.LinearLayout; Then you should have the old AdMob code to generate banners, right below super.loadUrl() code, similar to this: AdView adView = new AdView(this, AdSize.BANNER, "xxxxxxxxxxxxxx"); LinearLayout layout = super.root; layout.addView(adView); layout.setHorizontalGravity(android.view.Gravity.CENTER_HORIZONTAL); adView.loadAd(new AdRequest()); This code is no longer working, replace all block with the following: AdView adView = new AdView(this); adView.setAdSize(AdSize.BANNER); adView.setAdUnitId("ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx"); LinearLayout layout = super.root; layout.addView(adView); layout.setHorizontalGravity(android.view.Gravity.CENTER_HORIZONTAL); AdRequest adRequest = new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR).build(); adView.loadAd(adRequest); Replace the setAdUnitId with the ad unit id of your app. AdSize.BANNER constant can be changed depending of your needings, we prefer SMART_BANNER constant for cross-devices compatibility and a better result. Remember to add emulator and/or your phisical test devices to avoid troubles on your AdMob account. Further info about this step can be found at this page. STEP 5: TEST AND PUBLiSH |
||
|
||