QueuedBidderManager (recommended)

Last updated on July 27, 2017

This is the recommended class for implementing OpenX BidderOpenX's header bidding solution. Bidder enables publishers to realize the true value of their direct and indirect inventory in real time. "Bidder" can also mean a program designed to bid in real time on inventory in the OpenX Ad Exchange. for Apps. This approach is useful during infinite scroll scenarios where more than one ad is visible on the screen at once. It also allows you to have a single, global queuedBidderManager for all ads of a given size or type in your app which can then be passed to views.

  1. Initialize the OpenX Bidder adapter.

    Activity context is needed by the OpenX adapter to initialize devicemanager, locationmanager, and networkmanager to enhance the adrequest.

    You may want to initialize logging during development. Allowed log levels are:




    if (!BFAConfiguration.isSDKInit) {
    	BFAConfiguration.initSDK(this, this, BFALogger.LogLevel.NONE);

    Tip: With INFO/WARN, if ad requests to OpenX are failing, you will know what's going on. The log messages will include the version of Bidder for Apps that you are using.

    Example log message:

    11-14 09:46:01.796 7626-7626/com.openx.openx_appstore_demo W/OpenXBidder: OpenX BidderForApps v2.0.0 - Bad server response - [Adunits field empty in JSON response!]

  2. Create an instance of QueuedBidderManager.

    QueuedBidderManager needs the following inputs.

    Required params:

    queuedBidderManager = new QueuedBidderManager(domain, adunit, adCallParameters, queueLength);
    //where, QueuedBidderManager(String bidderDomain, String bidderAdUnit, AdCallParams adCallParameters, int queueLength)
  3. Call start() on QueuedBidderManager.

    Once start is called on the QueuedBidderManager, it begins to fill up its queue with ads and automatically replenishes itself when we pull ads out of it with dequeueAd. When dequeueing, higher bids come out first.

    Default queue length is 1: We recommend that the queue be left at the default of 1 to ensure minimal latency for prefetching ads.

    For scenarios when your app requires multiple ads in a shorter time frame, such as infinite scroll, you can set the queue for up to a maximum of 3. QueuedBidderManager will stop requesting new ads when the queue is filled up with 3 ads. Bid failures take up a slot in the queue with a BidderResponseContainer with a -1 price.

    Typically, a bid failure would be caused by the app user losing their internet connection, but it could also be due to failures to receive a bid with non-zero price. Therefore, please check for the valid bid value > 0, before using it.

    Dequeue an ad for initial ad load:

    protected void onCreate(Bundle savedInstanceState) {
    	BidderResponseContainer container = queuedBidderManager.dequeueAd();
    	if (container != null && container.preBidValue > 0) {
    		//combine your keywords with OpenX keywords m_ox & m_cache_key
    		String combinedKeywords = container.setOpenXKeywords(mopubView.getKeywords());
    		//pass in mopubView in localextras, so that can be used in OXMBannerCustomEvent class on OpenX win
    		Map < String, Object > localExtras = mopubView.getLocalExtras();
    		localExtras.put("view", mopubView);
    		//set all keywords on MopubView
    	//Send Mopub request
  4. Refresh an ad.

    Implement the listeners BannerAdListener/InterstitialAdListener in which you will dequeue another ad and update the MopubViews's keywords. This will allow auto refresh to work seamlessly:

    Dequeue an ad for an auto refresh:

    public void onBannerLoaded(MoPubView banner) {
    	BidderResponseContainer container = queuedBidderManager.dequeueAd();
    	if (container != null && container.preBidValue > 0) {
    		//remove old OpenX keywords from MopubView's
    		String kvWithNoBidderVal = container.removeOpenXKeywords(mopubView.getKeywords());
    		//add new OpenX keywords to the above kvWithNoBidderVal
    		String kvWithBidderVal = container.setOpenXKeywords(kvWithNoBidderVal);
    		//set localextras with this mopubview
    		Map < String, Object > localExtras = eachMopubView.getLocalExtras();
    		localExtras.put("view", eachMopubView);
    		//set MopubView's keywords, so that can be used in OXMBannerCustomEvent class on OpenX win
    		if (TextUtils.isEmpty(kvWithBidderVal)) {
  5. Implement MopubView’s AdClick listeners for banners and interstitialsA full-screen ad displayed in content transitions. For example, a video ad that loads between levels of a mobile game. to record clicks for OpenX, if OpenX wins.
    //For banners:
    public void onBannerClicked(MoPubView banner) {
    	if(OXMBannerCustomEvent.OXWinner) {
    	//From this mopubview, get its container from the hashmap. And let container do the click tracking. 
    	//In this example, MopubViewsArray is a map containing MopubViews & their containers.
    		BidderResponseContainer eachMopubViewContainer = mopubViewsArray.get(banner);
    		if (eachMopubViewContainer != null) {
    			//Make it false to facilitate new bid request for a new result.
    			OXMBannerCustomEvent.OXWinner = false;
    //For interstitials:
    public void onInterstitialClicked(MoPubInterstitial interstitial) {
    	if(OXMInterstitialCustomEvent.OXWinner) {
    		//Make it false to facilitate new bid request for a new result.
    		OXMInterstitialCustomEvent.OXWinner = false;
  6. Call QueuedBidderManager's destroy() on your app destroy.
public void onDestroy() {


Once you have set up QueuedBidderManager, the next step is to build data enrichment into your integration. Data enrichment can help increase revenue by revealing the value of your inventoryAd space available on a website or app. The basic unit of inventory for OpenX is an ad unit. to buyers.

Important: Please review the setup checklist. You must complete the self-test before submitting a build to OpenX for final testing. Do not submit your app to the app store before OpenX completes final testing.

See also:

Data enrichment

Bidder for Apps self-testing

Setup checklist