Today, we’re excited to announce the launch of new Google Mobile Ads APIs as part of the Google Play services 4.1 update. The update includes:
This release adds new DFP specific APIs to the com.google.android.gms.ads.doubleclick package. For example, you can use the new APIs to request a 320x50 banner ad from DFP as follows:
Check out the DFP docs for more examples on how to use the new DFP APIs. If you’re migrating from the old AdMob Android SDK to Google Play services, be sure to also consult our migration guide which summarizes implementation details for the new APIs.
Search Ads for Apps support has also been added in this release, with new APIs in the com.google.android.gms.ads.search package. A search ads banner request in Google Play services looks like this:
Consult the Search Ads documentation for more information on how to customize your The latest release now supports DoubleClick Ad Exchange, which shares the same See the Ad Exchange documentation for more information on implementing Ad Exchange with the new library.
We’ve added back the setLocation method to enable you to provide location to an ad request. Note that location should only be provided if your app already makes use of location.
Assuming you’ve grabbed location via a suitable method, you can pass the location when building an The new library can be downloaded from Android’s SDK manager. Consult the setup guide for detailed installation instructions. You can see a full list of changes on our release notes page.
Give us a shout on our forum with any questions or concerns about the release, and stay tuned on our G+ page for the latest updates (and maybe even a tips/tricks campaign!) on Google Mobile Ads APIs.
DoubleClick for Publishers
PublisherAdView adView = new PublisherAdView(this);
adView.setAdUnitId("MY_DFP_AD_UNIT_ID");
adView.setAdSizes(AdSize.BANNER);
LinearLayout layout = (LinearLayout) findViewById(R.id.mainLayout);
layout.addView(adView);
PublisherAdRequest request = new PublisherAdRequest.Builder().build();
adView.loadAd(request);
Search Ads for Apps
SearchAdView adView = new SearchAdView(this);
adView.setAdUnitId("MY_ADSENSE_ID");
adView.setAdSize(new AdSize(320, 60));
LinearLayout layout = (LinearLayout) findViewById(R.id.mainLayout);
layout.addView(adView);
SearchAdRequest request = new SearchAdRequest.Builder()
.setQuery("flower")
.build();
adView.loadAd(request);
SearchAdRequest.
DoubleClick Ad Exchange
AdView and
AdRequest classes with AdMob in Google Play Services:
adView = new AdView(this);
adView.setAdUnitId("MY_AD_EXCHANGE_ID");
adView.setAdSize(AdSize.BANNER);
LinearLayout layout = (LinearLayout) findViewById(R.id.mainLayout);
layout.addView(adView);
AdRequest request = new AdRequest.Builder().build();
adView.loadAd(request);
Location
AdRequest:
Location location = … // get location.
AdRequest request = AdRequest.Builder().setLocation(location).build();