public interface BidResponseListener
| Modifier and Type | Method and Description |
|---|---|
void |
onResponse(Bid bid)
Callback invoked when a response for a bid is given to the publisher.
|
@UiThread
void onResponse(@Nullable
Bid bid)
In case of no bid, the given response is null. In case of successful bid, the given response is not
null and its CPM is accessible through Bid.getPrice().
CriteoBannerView.loadAd(Bid): display a bannerCriteoInterstitial.loadAd(Bid): display an interstitialCriteoNativeLoader.loadAd(Bid): display a native ad
Please note that the loadAd method should match the kind of AdUnit the bid was asked for.
Criteo.enrichAdObjectWithBid(Object, Bid) method, to enrich your ad server object.
WeakReference to capture Activity or View (or any big
object)
class MyActivity extends Activity {
private CriteoBannerView bannerView;
void sample() {
// This is an anonymous class, "this" is implicitly hold and is retained until listener is notified
Criteo.getInstance().loadBid(adUnit, new BidResponseListener() {
});
// "this" is explicitly held and is retained until listener is notified
Criteo.getInstance().loadBid(adUnit, bid -> {
this.bannerView.loadAd(bid);
});
// "this" is weakly held and is not retained
WeakReference≶MyActivity> weakThis = new WeakReference(this);
Criteo.getInstance().loadBid(adUnit, bid -> {
MyActivity activity = weakThis.get();
if (activity != null) {
activity.bannerView.loadAd(bid);
}
});
}
}
bid - null in case of no bid, or a bid object that can be used to display an AdCriteo.loadBid(AdUnit, BidResponseListener)