1

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?

H.JiMan
  • 269
  • 1
  • 2
  • 10

1 Answers1

0

Initialize ads in the application file of your project.

Check meta data in manifest file

Always test with test ads ca-app-pub-3940256099942544/3419835294

Add app-ads.txt file on testing server or any blogger

For More Information Refer this https://developers.google.com/admob/android/app-open

Jayesh Dankhara
  • 525
  • 7
  • 8