Simpler testing with new AdMob test ads
![Share on Twitter](https://cdn.statically.io/img/www.gstatic.com/images/icons/material/system/2x/post_twitter_black_24dp.png)
![Share on Facebook](https://cdn.statically.io/img/www.gstatic.com/images/icons/material/system/2x/post_facebook_black_24dp.png)
Kotlin and the Google Mobile Ads SDK
![Share on Twitter](https://cdn.statically.io/img/www.gstatic.com/images/icons/material/system/2x/post_twitter_black_24dp.png)
![Share on Facebook](https://cdn.statically.io/img/www.gstatic.com/images/icons/material/system/2x/post_facebook_black_24dp.png)
Mobile Ads Garage #3: Banner ad best practices
![Share on Twitter](https://cdn.statically.io/img/www.gstatic.com/images/icons/material/system/2x/post_twitter_black_24dp.png)
![Share on Facebook](https://cdn.statically.io/img/www.gstatic.com/images/icons/material/system/2x/post_facebook_black_24dp.png)
The Mobile Ads Garage: A new video series about using the Google Mobile Ads SDK
![Share on Twitter](https://cdn.statically.io/img/www.gstatic.com/images/icons/material/system/2x/post_twitter_black_24dp.png)
![Share on Facebook](https://cdn.statically.io/img/www.gstatic.com/images/icons/material/system/2x/post_facebook_black_24dp.png)
Adding SDK-less mediation to your project
![Share on Twitter](https://cdn.statically.io/img/www.gstatic.com/images/icons/material/system/2x/post_twitter_black_24dp.png)
![Share on Facebook](https://cdn.statically.io/img/www.gstatic.com/images/icons/material/system/2x/post_facebook_black_24dp.png)
Announcing the Google Mobile Ads API Demo apps
![Share on Twitter](https://cdn.statically.io/img/www.gstatic.com/images/icons/material/system/2x/post_twitter_black_24dp.png)
![Share on Facebook](https://cdn.statically.io/img/www.gstatic.com/images/icons/material/system/2x/post_facebook_black_24dp.png)
Announcing two new versions of the Google Mobile Ads SDK, plus the Native Ads beta!
![Share on Twitter](https://cdn.statically.io/img/www.gstatic.com/images/icons/material/system/2x/post_twitter_black_24dp.png)
![Share on Facebook](https://cdn.statically.io/img/www.gstatic.com/images/icons/material/system/2x/post_facebook_black_24dp.png)
From a DFP Line Item to Mobile Ads SDK Code
![Share on Twitter](https://cdn.statically.io/img/www.gstatic.com/images/icons/material/system/2x/post_twitter_black_24dp.png)
![Share on Facebook](https://cdn.statically.io/img/www.gstatic.com/images/icons/material/system/2x/post_facebook_black_24dp.png)
Announcing v7.0 of the Google Mobile Ads SDK for Android
![Share on Twitter](https://cdn.statically.io/img/www.gstatic.com/images/icons/material/system/2x/post_twitter_black_24dp.png)
![Share on Facebook](https://cdn.statically.io/img/www.gstatic.com/images/icons/material/system/2x/post_facebook_black_24dp.png)
Rollback of roadblocks feature in the Mobile Ads SDK
![Share on Twitter](https://cdn.statically.io/img/www.gstatic.com/images/icons/material/system/2x/post_twitter_black_24dp.png)
![Share on Facebook](https://cdn.statically.io/img/www.gstatic.com/images/icons/material/system/2x/post_facebook_black_24dp.png)
Announcing version 7.0.0 of the Google Mobile Ads SDK for iOS
![Share on Twitter](https://cdn.statically.io/img/www.gstatic.com/images/icons/material/system/2x/post_twitter_black_24dp.png)
![Share on Facebook](https://cdn.statically.io/img/www.gstatic.com/images/icons/material/system/2x/post_facebook_black_24dp.png)
New Google Mobile Ads SDK Adds Support for DFP, Search Ads, and Ad Exchange
![Share on Twitter](https://cdn.statically.io/img/www.gstatic.com/images/icons/material/system/2x/post_twitter_black_24dp.png)
![Share on Facebook](https://cdn.statically.io/img/www.gstatic.com/images/icons/material/system/2x/post_facebook_black_24dp.png)
Using DFP App Events with the Google AdMob SDK
The next step is to have the application code listen for these app events. Here are the iOS and Android versions of this method, respectively:
// iOS - (void)adView:(DFPBannerView *)banner didReceiveAppEvent:(NSString *)name withInfo:(NSString *)info { NSLog(@"Received app event (%@, %@)", name, info); // Checking for a "color" event name with information being a color. if ([name isEqualToString:@"color"]) { if ([info isEqualToString:@"red"]) { self.view.backgroundColor = [UIColor redColor]; } else if ([info isEqualToString:@"green"]) { self.view.backgroundColor = [UIColor greenColor]; } } } // Android @Override public void onAppEvent(Ad ad, String name, String info) { String message = String.format("Received app event (%s, %s)", name, info); Log.d(LOG_TAG, message); if ("color".equals(name)) { LinearLayout layout = (LinearLayout) findViewById(R.id.mainLayout); if ("red".equals(info)) { layout.setBackgroundColor(Color.RED); } else if ("green".equals(info)) { layout.setBackgroundColor(Color.GREEN); } } }
Remember to register this callback on the banner view:
// iOS [bannerView_ setAppEventDelegate:self]; // Android adView.setAppEventListener(this);
That’s it! If you load this ad into your banner view, your application will change its background color to red when the ad is loaded, and green when the ad is clicked. This example can be extended to change the implementation of the app event listener or to fire app events at any point during the creative’s lifecycle.
Let us know on the forum if you have any questions about app events specifically or the Google AdMob SDK in general. You can also follow us on our plus page for AdMob-related updates.
Edit: Fixed plus page link.
- Eric Leichtenschlag, AdMob Team
![Share on Twitter](https://cdn.statically.io/img/www.gstatic.com/images/icons/material/system/2x/post_twitter_black_24dp.png)
![Share on Facebook](https://cdn.statically.io/img/www.gstatic.com/images/icons/material/system/2x/post_facebook_black_24dp.png)
Announcing v201208 of the DFP API
![Share on Twitter](https://cdn.statically.io/img/www.gstatic.com/images/icons/material/system/2x/post_twitter_black_24dp.png)
![Share on Facebook](https://cdn.statically.io/img/www.gstatic.com/images/icons/material/system/2x/post_facebook_black_24dp.png)