Interstitial
Overview
Loading interstitial ads consists of several stages:
- Loading BidMachine InterstitialRequest
- Setting up AdMob AdRequest by loaded BidMachine InterstitialRequest
- Loading AdMob InterstitialAd with configured AdMob AdRequest
Loading BidMachine InterstitialRequest
Create a new InterstitialRequest instance with AdRequestListener.
Execute request
on the InterstitialRequest 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 InterstitialRequest instance
InterstitialRequest interstitialRequest = new InterstitialRequest.Builder()
.setListener(new InterstitialRequest.AdRequestListener() {
@Override
public void onRequestSuccess(@NonNull InterstitialRequest interstitialRequest,
@NonNull AuctionResult auctionResult) {
runOnUiThread(() -> loadAdMobInterstitial(interstitialRequest));
}
})
.build();
// Request an ad from BidMachine without loading it
interstitialRequest.request(...);
Setting up AdMob AdRequest
Ways to set up AdMob AdRequest by BidMachine InterstitialRequest:
- Create a new AdMob AdRequest instance
AdRequest adRequest = BidMachineUtils.createAdRequest(interstitialRequest);
- Create a new AdMob AdRequest.Builder instance
AdRequest.Builder adRequestBuilder =
BidMachineUtils.createAdRequestBuilder(interstitialRequest);
AdRequest adRequest = adRequestBuilder.build();
- Fill an existing AdMob AdRequest.Builder instance
AdRequest.Builder adRequestBuilder = new AdRequest.Builder();
BidMachineUtils.appendRequest(adRequestBuilder, interstitialRequest);
AdRequest adRequest = adRequestBuilder.build();
Loading AdMob InterstitialAd
Use the AdMob AdRequest that was created during the previous step to load the AdMob InterstitialAd.
InterstitialAd.load(..., ..., adRequest, ...);
Sample App
You can find Sample App with BidMachineSDK and AdMob here: Github Interstitial
Updated about 1 year ago
What’s Next