Display banner on Android

Display AdropBanner

Initialize AdropBanner with ad unit ID, then load ad. add banner to area you want when onAdReceived callback

val adContainer: FrameLayout // your Ad container
val banner: AdropBanner = AdropBanner(applicationContext, unitId)
banner.listener = object : AdropBannerListener {
    override fun onAdReceived(banner: AdropBanner) {
        adContainer.removeAllViews()
        adContainer.addView(banner)
    }

    override fun onAdClicked(banner: AdropBanner) {
        Log.d("Adrop", "${banner.getUnitId()}, onAdClicked")    
        // "{unitId}, onAdClicked"
    }
    
    override fun onAdFailedToReceive(banner: AdropBanner, error: AdropErrorCode) {
        removeView(banner)
    }
}

// request ad to server
banner.load()

Destroy

When you are done showing your AdropBanner, you should destroy it so that the ad is properly garbage collected.

banner.destroy()

Last updated