android - Upgrading AdMob SDK and fail on load() method -
I'm working to update to the new AdMob which requires Google services to work. I am using this code in Critical ()
AdView adView = (AdView) this.findViewById (R.id.adView); // AdRequest AdRequest adRequest = new AdRequest.builder (). AddTestDevice (AdRequest.DEVICE_ID_EMULATOR) .build (); AdView.loadAd (adRequest); Log D. ("ADMOB", "successfully loaded"); and using this code in XML
& lt; com.google.android.gms.ads.AdView xmlns: ads = "http: // Schema.android.com/apk/res-auto" android: id = "@ + id / adView" Android: layout_width = "match_parent" Android: layout_height = "wrap_content" android: layout_alignParentBottom = "true" android: layout_gravity = "center_horizontal" ad: adSize = "SMART_BANNER" ad: adUnitId = "ADMOB_ID" /> However, adMob ad is not displayed Try / hold block fails here:
adView.loadAd (adRequest); The AndroidManifest code looks like this:
& lt; Meta-Data Android: name = "com.google.android.gms.version" Android: value = "@ integer / google_play_services_version" /> & Lt; Activity Android: name = "com.google.android.gms.ads.AdActivity" Android: configChanges = "keyboard | keyboardHidden | Orientation | Screen Layout | uiMode | Screensize | Small Screen Size" / & gt; What am I missing?
I quote
create the next, on-activated method. This is where you will build and load AdRequest. Refer to AdView, then build and load AdRequest.
Therefore, you have to implement it like this:
@Override is operated on public Zero (bundle bundle) {super. Oral activity (bundle); AdView mAdView = (AdView) getView () FindViewById (R.id.adView); AdRequest adRequest = new AdRequest.builder (). Build (); MAdView.loadAd (adRequest); }
Comments
Post a Comment