Android Banner Configuration

1. Set Up the Banner Ad Delegate Method

For Java

Yodo1Mas.getInstance().setBannerListener(new Yodo1Mas.BannerListener() {
    @Override
    public void onAdOpened(@NonNull Yodo1MasAdEvent event) {
    
    }

    @Override
    public void onAdError(@NonNull Yodo1MasAdEvent event, @NonNull Yodo1MasError error) {
    
    }

    @Override
    public void onAdClosed(@NonNull Yodo1MasAdEvent event) {
    
    }
});

For Kotlin

val bannerListener: Yodo1Mas.BannerListener = object : Yodo1Mas.BannerListener() {
override fun onAdOpened(event: Yodo1MasAdEvent) {

            }
override fun onAdError(event: Yodo1MasAdEvent, error: Yodo1MasError) {
                Toast.makeText(this@MainActivity, error.message, Toast.LENGTH_SHORT).show()
            }
override fun onAdClosed(event: Yodo1MasAdEvent) {

            }
}
Yodo1Mas.getInstance().setBannerListener(bannerListener)

2. Show Banner Ad

This method uses the default parameters; for alignment: Yodo1Mas.BannerTop | Yodo1Mas.BannerHorizontalCenter and offset(X: 0,Y: 0)

For Java

Yodo1Mas.getInstance().showBannerAd(MyActivity.this);

For Kotlin

Yodo1Mas.getInstance().showBannerAd(this@MainActivity)

You can customize the banner alignment by using the default offset(X: 0, Y: 0)

For Java

int align = Yodo1Mas.BannerTop | Yodo1Mas.BannerHorizontalCenter;
Yodo1Mas.getInstance().showBannerAd(MyActivity.this, align);

For Kotlin

val align = Yodo1Mas.BannerBottom or Yodo1Mas.BannerHorizontalCenter
Yodo1Mas.getInstance().showBannerAd(this@MainActivity, align)

You may use this method to customize banner alignment and offset.

For Java

int align = Yodo1Mas.BannerTop | Yodo1Mas.BannerHorizontalCenter;
int offsetX = 10;
int offsetY = 10;
Yodo1Mas.getInstance().showBannerAd(MyActivity.this, align, offsetX, offsetY);

For Kotlin

val align = Yodo1Mas.BannerBottom or Yodo1Mas.BannerHorizontalCenter
val offsetX = 0
val offsetY = 0
Yodo1Mas.getInstance().showBannerAd(this@MainActivity, align, offsetX, offsetY)

3. Dismiss Banner Ad

For Java

Yodo1Mas.getInstance().dismissBannerAd();

For Kotlin

Yodo1Mas.getInstance().dismissBannerAd()
Updated on September 22, 2021

Was this article helpful?

Related Articles