AdListener

public class AdListener extends Object

A listener to be provided to the SearchAdController for receiving notifications when ads have been loaded, clicked on, or have failed to load due to an error.

Constant Summary

int ERROR_CODE_INTERNAL_ERROR
int ERROR_CODE_INVALID_REQUEST
int ERROR_CODE_NETWORK_ERROR
int ERROR_CODE_NO_FILL

Public Constructor Summary

Public Method Summary

void
onAdFailedToLoad(int errorCode)
Called when a request to load ads fails.
void
onAdLeftApplication()
Called when an ad has been clicked and is being opened in a browser.
void
onAdLoaded()
Called when a request to load ads finishes.
void
onSpaAdClicked(String sku, String itemGroupId)
Called when a Sponsored Product ad is clicked (other than an add-to-cart link in the ad).
void
onSpaAddToCartClicked(String sku, String itemGroupId)
Called when an add-to-cart link in a Sponsored Product ad is clicked.

Inherited Method Summary

Constants

public static final int ERROR_CODE_INTERNAL_ERROR

Constant Value: 0

public static final int ERROR_CODE_INVALID_REQUEST

Constant Value: 1

public static final int ERROR_CODE_NETWORK_ERROR

Constant Value: 2

public static final int ERROR_CODE_NO_FILL

Constant Value: 3

Public Constructors

public AdListener ()

Public Methods

public void onAdFailedToLoad (int errorCode)

Called when a request to load ads fails.

Error codes are one of ERROR_CODE_INTERNAL_ERROR, ERROR_CODE_INVALID_REQUEST, ERROR_CODE_NETWORK_ERROR, or ERROR_CODE_NO_FILL.

This callback will not be called for a request that was pre-empted by a new call to loadAds(SearchAdRequest) before the first request completed.

Parameters
errorCode

public void onAdLeftApplication ()

Called when an ad has been clicked and is being opened in a browser.

public void onAdLoaded ()

Called when a request to load ads finishes.

The total number of ads loaded may be checked with numAdsLoaded().

This callback will not be called for a request that was pre-empted by a new call to loadAds(SearchAdRequest) before the first request completed. If getPrefetch() is true and additional ads are fetched as necessary, this callback will be called each time a new batch of ads is loaded. Hence this callback could be called zero, one, or multiple times for a single call to loadAds.

public void onSpaAdClicked (String sku, String itemGroupId)

Called when a Sponsored Product ad is clicked (other than an add-to-cart link in the ad).

public void onSpaAddToCartClicked (String sku, String itemGroupId)

Called when an add-to-cart link in a Sponsored Product ad is clicked.