Entry point for the API for AdSense for Search (AFS) native Custom Search Ads (CSA).
Each ad context should have a separate
SearchAdController. For example, if
you have a page which shows ads alongside a list of search results, and other page which
shows ads alongside details for a specific product, you should use two separate
SearchAdController should be used with the following flow:
- Create the
SearchAdControllerusing the constructor, providing a listener to be notified when ads are loaded.
createAdView()to create an empty view to hold ads. Do not place the view into your view hierarchy yet.
- When the user makes a search query, call
- When your listener's
onAdLoadedmethod is called, call
populateAdView(View, String)to place ads into the view previously created with
createAdView. Place the view into your view hierarchy. You can populate up to
numAdsLoaded()views with ads.
- When the user makes a new search query, call
loadAdsand repeat the above.
Public Constructor Summary
Public Method Summary
Inherited Method Summary
public static final int IS_EXPERIMENT_CONTROL
public static final int IS_EXPERIMENT_VARIANT
public static final int NOT_SELECTED_FOR_EXPERIMENT
public SearchAdController (Context context, String partnerId, String styleId, SearchAdOptions options, AdListener adListener)
Creates a new
|context||The context the
|partnerId||The publisher id, e.g. "ms-app-pub-9616389000213823"|
|styleId||The style id for the template that will be used to render native ads|
|options||Configuration options, such as whether to prefetch ads|
|adListener||Listener for receiving notifications when ads are loaded and other events|
public View createAdView ()
Creates an empty ad view that can be populated with a single ad with
This same view can be recycled to display multiple ads over time with subsequent
public int experimentVariantStatus ()
public void loadAds (SearchAdRequest searchAdRequest)
Loads ads into the cache and discards any previously loaded ads, indicating a new user search.
|searchAdRequest||The ad request containing the user query and other options.|