Please find the sample code below :
fun loadCollapsibleBannerAd() {
adview = AdView(this.applicationContext)
adview.adUnitId = "ca-app-pub-3940256099942544/2014213617"
val adSize = getAdSize()
adview.setAdSize(adSize)
val extras = Bundle()
extras.putString("collapsible", "bottom")
val adRequest = AdRequest.Builder()
.addNetworkExtrasBundle(AdMobAdapter::class.java, extras)
.build()
binding.bannerContainer.addView(adview)
adview.loadAd(adRequest)
} Currently, I'm using a test ad unit for a collapsible banner. If I pass the
activity context while creating the instance of AdView, the ad expands as expected. However, when I use the
application context, the ad does not expand. This limitation prevents me from preloading the ad before the activity is opened and it is easily reproducible.
On Monday, 27 January 2025 at 07:18:06 UTC+5:30 Ankit Chandora wrote:
I'm facing an issue where banner ads in Google Ad Manager require the activity context to load the ad. If we don't pass the activity context then the loaded ad is not expanding. This blocks us from preloading ads, as preloading happens before the activity is opened. How can we preload ads effectively in this scenario?