Android Ad Publishing¶
You can serve native, video, interstitial and banner ads very quickly and with little effort using Yahoo App Publishing and the Flurry SDK.
Important
Flurry SDK requires Android API level 10 and higher.
About¶
The Flurry SDK provides you with an object-based API to create objects for Native, Interstitial and Banner ads. This means that you can use individual objects to control the lifecycle of an ad.
To take advantage of new Flurry App Publishing features, Flurry recommends that you get the new Flurry SDK and integrate your Android app.
To view source code for Android apps with different banner, interstitial and native ad integrations, Download the Flurry sample code on Github.
In addition, the sample Yodel Android app shows different types of native ad placement, including vertical and horizontal streams of data interspersed with native ads. The source code for that sample is available on Github.
Important
Flurry SDK requires Android API level 10 and higher.
Flurry Advertising uses the Android Advertising ID provided by Google Play Services and will check for and respect the user’s ad tracking preference. For more information, visit Android Advertising ID.
Native Ads Integration Code¶
Before you begin native ad integration, you may wish to review the Native Ad Design Guidelines. The guidelines are intended to help you build engaging ad experiences while protecting the integrity of your advertisers’ brand assets. You need to adhere to these guidelines when implementing Yahoo native ads in your apps.
For a quick view of the native ads in an app, you can build and run the Flurry sample Android app that serves the native ads. The sample Yodel app shows a vertical and horizontal stream of Tumblr blogs with native ads blended in. The sample is available on Github.
To integrate Flurry Native Ads into your app, you need to use Flurry Android SDK 5.x and above. To integrate Flurry Native Video Ads into your app, you need to use the Flurry Android SDK 5.6 and above.
To work with Flurry Android Native ads, follow these required configuration steps:
Step 1. Before you can integrate the code into your application, you will need to configure the ad unit that your code references on the Flurry dev portal (http://y.flurry.com). For native ads, the ad unit is configured as the “Stream” ad placement. For detailed instructions on how to configure Stream ad units, see Creating Native Stream Ad Spaces.
The current version of native ads supports static (image) and video ads. The video ads are mixed in with the static ads.
For all other ad unit placements, follow these detailed instructions on how to configure an ad unit: Basic Ad Space Setup.
Note that after you create a Stream ad unit on the dev portal, it takes about one hour for the ad unit to start serving ads and for the ad unit to become active.
For each Activity where Native ads are served, use a single ad unit. This ad unit can be referenced multiple times in multiple locations within the Activity. For example, if the native ad is placed in multiple cells of a table view, it would be referencing the same ad unit name. This ad unit can serve both image and video ads.
Step 2. Integrating code for native displays requires fetching the ad assets and displaying the ad in a custom view that matches the application layout.
Create the ad view to contain the ad assets. Place this view within another view of your app.
Step 3. Initialize the native ad, assign the FlurryAdNativeListener and request the ad from Flurry:
You can create multiple native ad objects at the same time. The SDK keeps track of the fetch requests the app makes and adds the returned assets to their corresponding ad objects as they are made ready. The app can destroy the native objects as it sees fit using the destroy() method of the ad object. Otherwise, they will be destroyed with the context that created them.
Note If your application supports the device rotation, use the application context when creating the native ad objects to prevent the object from being destroyed with the Activity.
Step 4.
In the app code, implement the FlurryAdNativeListener to receive the callbacks related to the ad’s lifecycle events. You will need to implement the following callback methods:
Step 5. Enable Native Ad Tracking
To enable impression and click tracking, call setTrackingView()
on the ad view created in the earlier step.
If you plan to re-use the view to show different ads, call removeTrackingView()
before setting the new ad tracking view.
Step 6. Parse the received assets and compose the view to display the ad.
For example, the following code snippet demonstrates the process:
For the static ads, Yahoo requires you, as the Publisher, to display the headline, advertiser name, one image and the branding logo. You can pick the image best suited for your requirements and crop the image to match your aspect ratio. For the video ads, Yahoo requires you, as the Publisher, to display the headline, advertiser name, video and the branding logo. We recommend the placeholder for video to be of the card size at least. We advise against placing the video into the pencil sized ads.
The potential assets and their key names are shown in the table below.
Name |
Type |
Description |
---|---|---|
summary |
STRING |
The call to action summary of the advertisement |
headline |
STRING |
The Ad headline, typically a single line |
source |
STRING |
The advertiser name |
objective |
STRING |
Indicates the ad objective, implicitly indicates the type of the ad returned, current values: INSTALL_APP and VISIT_WEB |
secBrandingLogo |
IMAGE |
The square image always present, size: 20 x 20px |
secHqBrandingLogo |
IMAGE |
The square high-quality image of the sponsored logo. Currently, it is a starburst.png, always present, size: 40 x 40px |
secOrigImg |
IMAGE |
The secured original image, size: 627px x 627px. Optional asset, not present for the video ads. |
secHqImage |
IMAGE |
The secured high quality image, size: 1200px x 627px. Optional asset, not present for the video ads. |
secImage |
IMAGE |
The secured image, size: 82px x 82px. Optional asset, not present for the video ads. |
secThumbnailImage |
IMAGE |
The secured image, size: 160px x 160px. Thumbnail image, Optional asset, not present for the video ads. |
appCategory |
STRING |
The app category. Optional asset, present only for the app install ads and some video ads. |
appRating |
STRING |
The app rating, expressed as 80/100 for the 4 star rating or 100/100 for the 5 star rating of the app. Optional asset, present only for the app install ads and some video ads. |
secRatingImg |
IMAGE |
The secured image representing the number of the stars the app is rated with. Optional asset, present only for the app install ads and some video ads. |
secHqRatingImg |
IMAGE |
The secured high-quality image representing the number of the stars the app is rated with. Optional asset, present only for the app install ads and some video ads. |
showRating |
STRING |
true or false value recommending whether to show the star rating of the app or not. Optional asset, present only for the app install ads. |
callToAction |
STRING |
The Call to Action string. |
collapseImg |
IMAGE |
The secured image representing the collapse button used for composing the expandable ads. |
expandImg |
IMAGE |
The secured image representing the expand button used for composing the expandable ads. |
The video ads do not have an explicit asset name and the video url is not exposed. Rather, the video ads are identified with the isVideoAd
property of the native ad object set to true
.
For all the assets whose type is Image, the value for the asset is a url string that links to the image. Note that the url points to either the local or remote resource:
Caching is enabled for the ad unit - default setting: The SDK caches the assets onto the device before it declares the ad ready. The asset’s url in FlurryAdNativeAsset points to the local file (url contains the locator in the form file:// ) where the asset resides.
Caching is not enabled for the ad unit: The assets are available via https url. Calling
loadAssetIntoView
orgetAssetView
on theFlurryAdNativeAsset
object loads the assets directly from the network and does not cache the assets.
If you wish to use the memory cache, Flurry recommends you load the images directly instead of using the loadAssetIntoView
method of FlurryAdNativeAsset
object.
The Video ads are cached on the device by the default.
Note about Native Video Ads For the ad units that are configured to receive video ads, each native video request allows for either video or static native ads to be returned. Other than rendering a native video ad, the integration steps for native video ads are the same as for native static ads.
To render a native video ad, you must use FlurryAdNativeAsset#loadAssetIntoView()
.
Expandable Ads¶
Starting with the Android SDK version 6.2.0, Flurry enables newer display format for native ads. You can choose to show the condensed ad view (also called Pencil ad format) with elements like title and summary. On tapping the ad, the ad view can be expanded to an elaborate view. This feature can be implemented by making use of the updated FlurryAdNative API and its updated FlurryAdNativeListener callbacks.
Two new methods are added to help set the tracking view in the collapsed as well as in the expanded display state.
Normally native ads need to set the tracking view to the view that contains the ad’s assets.
For the expandable display, there are two new methods provided to set the tracking view referencing the expand button and the CTA button. When the ad is in the collapsed view, this view contains the expand button. Setting the setPencilViewToTrack on the collapsed ad allows the SDK to monitor for the user’s click on the expand button.
Similarly, when the ad is in the collapsed view, it contains the CTA button. Setting the setExpandedViewToTrack on the expanded view, allows the SDK to monitor for the user’s click on the CTA button.
If you start from the condensed view:
Or, if you start from the expanded view:
Note: The CTA view can’t be null. The CTA view in the condensed view can be used to launch the landing page, or it can be an invisible view to disable the feature. By providing the CTA view, the end user can open the landing page without expanding the ad.
- Note: The Collapse button in the expand view can be used to collapse the view.
The Collapse button can be null. In such a case, collapsing back to the condensed view will be disabled.
Setting the condensed view or expanded view using the APIs will not require you to set tracking view separately.
Flurry SDK provides a delegate callback to notify when the display state is changed by either tapping on the condensed view or tapping the collapse button.
The FlurryAdNativeListener can implement this callback and respond appropriately as follows:
Step 7. Build & Run the Sample Code App.
If you build and run the sample app, the native ad integrated into the app looks like this:

If you are not seeing any ads, check the troubleshooting section in FAQs for Android.
Interstitial Ads Integration Code¶
Because every app is different, Flurry encourages you to experiment to find what works best.
Use Flurry Analytics to determine places in your app with the highest user traffic. Typically, good placements include:
Games: On game launch, when the user completes a level
Social Networks: User completes an engagement (call, text, video)
Entertainment: User completes consuming media (video, music)
Content & Media: User completes consuming content
Utility: User completes using the tool
The following section shows an example of an interstitial integration. The
basic steps involve fetching an ad and displaying the ad when it is
prepared and made available. Interstitials ad serving flow is best
implemented with the fetchAd
and displayAd
methods and the
FlurryAdListener
interface.
To be notified of certain events during the full lifecycle of the Ad, implement the FlurryAdInterstitialListener
interface and then call the setListener
method to attach your implementation of FlurryAdInterstitialListener
to the Flurry SDK. You will need to implement the following callback methods:
Run the app to see an Interstitial ad display.
You should now see an ad similar to the following:

If you are not seeing any ads, check the troubleshooting section in FAQs for Android.
Configure Ad serving (Optional)¶
You can use a number of configuration parameters to modify the behavior of your ad units.
Test Mode
Setting an ad unit into test mode is meant to help you validate your integration. Test mode removes any content or geo filtering before delivering ads into the ad unit. Note that only ads from the Flurry network can be placed into test mode. Ads served from RTB networks are not available in test mode.
To configure your ad unit for test mode:
User Cookies
Add a call to identify any user-specific information you want associated with the ad request:
Learn More¶
For detailed information on the Java classes and methods available in the SDK, check out the API Reference documentation for Android.