Loading native ads consists of several stages:

  1. Loading BidMachine NativeRequest
  2. Setting up AdMob AdRequest by loaded BidMachine NativeRequest
  3. Loading native ad through AdMob AdLoader with configured AdMob AdRequest

Loading BidMachine NativeRequest

Create a new NativeRequest instance with AdRequestListener.
Execute request on the NativeRequest instance to start loading.
When the onRequestSuccess callback is triggered, it means that the request has been successfully loaded and you can proceed to AdMob AdRequest settings.

// Create new BidMachine NativeRequest instance
NativeRequest nativeRequest = new NativeRequest.Builder()
        .setListener(new NativeRequest.AdRequestListener() {
            public void onRequestSuccess(@NonNull NativeRequest nativeRequest,
                                         @NonNull AuctionResult auctionResult) {
                runOnUiThread(() -> loadAdMobNative(nativeRequest));

// Request an ad from BidMachine without loading it

Setting up AdMob AdRequest

Ways to set up AdMob AdRequest by BidMachine NativeRequest:

  1. Create a new AdMob AdRequest instance
AdRequest adRequest = BidMachineUtils.createAdRequest(nativeRequest);
  1. Create a new AdMob AdRequest.Builder instance
AdRequest.Builder adRequestBuilder =
AdRequest adRequest = adRequestBuilder.build();
  1. Fill an existing AdMob AdRequest.Builder instance
AdRequest.Builder adRequestBuilder = new AdRequest.Builder();
BidMachineUtils.appendRequest(adRequestBuilder, nativeRequest);
AdRequest adRequest = adRequestBuilder.build();

Loading native ad through AdMob AdLoader

Use the AdMob AdRequest that was created during the previous step to load native ad through AdMob AdLoader.

// Create new AdLoader instance
AdLoader adLoader = new AdLoader.Builder(..., ...)

// Load native ad with AdMob AdRequest


Sample App

You can find Sample App with BidMachineSDK and AdMob here: Github Native