I put Admob in the middle of the current RecyclerView. Implemented as follows with native admob.
adLoader = AdLoader.Builder(mContext, mContext.resources.getString(R.string.admob_unit_id))
.forNativeAd { nativeAd ->
if (!adLoader.isLoading) {
// Inserting advertisements in the middle of items in RecyclerView
}
}
.withAdListener(object : AdListener() {
override fun onAdFailedToLoad(errorCode: LoadAdError) {
super.onAdFailedToLoad(errorCode)
}
override fun onAdClosed() {
super.onAdClosed()
Log.d("Activity", "TEST ad onAdClosed ....${adLoader.isLoading}")
}
override fun onAdOpened() {
super.onAdOpened()
Log.d("Activity", "TEST ad onAdOpened ....${adLoader.isLoading}")
}
override fun onAdLoaded() {
super.onAdLoaded()
Log.d("Activity", "TEST ad onAdLoaded ....${adLoader.isLoading}")
}
override fun onAdClicked() {
super.onAdClicked()
Log.d("Activity", "TEST ad onAdClicked ....${adLoader.isLoading}")
}
override fun onAdImpression() {
super.onAdImpression()
Log.d("Activity", "TEST ad onAdImpression ....${adLoader.isLoading}")
}
})
.withNativeAdOptions(NativeAdOptions.Builder().build())
.build()
adLoader.loadAds(AdRequest.Builder().build(), 5)
In the code above, the onAdLoaded()
function of the ad loading process is called. But when I click on the ad in the RecyclerView, nothing happens. How do I fix it?