Android Banner Integration

Last Updated on: 19 Sep, 2023

Create a Banner Object

INFO

If you miss to Initialize the SDK, this method will fail to return a response.

To implement a Banner bidder object for GAM follow:

Kotlin

val mesonGAMBanner = MesonGAMBanner("<Adunit Id>", AdSize(<width>, <height>))

Java

MesonGAMBanner mesonGAMBanner = new MesonGAMBanner("<Adunit id>", new AdSize(<width>, <height>));

Fetch a Bid

To fetch a bid for GAM follow:

Kotlin

//Fetch bid by supplying publisher created DFP's AdManagerAdRequest Builder instance.

mesonGAMBanner.fetchBid(pubInstance, object : MesonAdFetchListener<AdManagerAdRequest.Builder> {
  override fun onComplete(obj: AdManagerAdRequest.Builder, error: Error?) {
    val adManagerAdRequest: AdManagerAdRequest = obj.build()
    //Load with publisher created dfpBanner instance 
    dfpBanner.loadAd(adManagerAdRequest);
  }
})

Java

//Fetch bid by supplying publisher created DFP's AdManagerAdRequest Builder instance.

mesonGAMBanner.fetchBid(pubInstance, new MesonAdFetchListener<AdManagerAdRequest.Builder>() {
  @Override
  public void onComplete(AdManagerAdRequest.Builder obj, @Nullable Error error) {
    AdManagerAdRequest adManagerAdRequest  = obj.build();
    //Load with publisher created dfpBanner instance
    dfpBanner.loadAd(adManagerAdRequest);
  }
});

WHAT'S NEXT

Next, let's integrate Interstitial ad units, or Manage Demand and Configure your Ad Server.