in Education by
I tried to set the adListener for Interstitial Ad but it doesn't work (AdMob + Kotlin - Mobile Ads Garage #13). After a bit digging I found that the methods adListener is deprecated, and is replaced with Instertitial Ad.load. I really don't know how to set a listener on ad this way(??) and I have searched all over the internet to find a solution for this. Please help. Thank you. Edit: I want to navigate to new fragment when the Instertitial Ad is dismissed (closed), so I tried: private fun showInterstitial() { mInterstitialAd?.fullScreenContentCallback = object : FullScreenContentCallback() { override fun onAdDismissedFullScreenContent() { Log.d(TAG, "Ad was dismissed.") // Don't forget to set the ad reference to null so you // don't show the ad a second time. mInterstitialAd = null view?.findNavController()?.navigate(action) } override fun onAdFailedToShowFullScreenContent(adError: AdError?) { Log.d(TAG, "Ad failed to show.") // Don't forget to set the ad reference to null so you // don't show the ad a second time. mInterstitialAd = null view?.findNavController()?.navigate(action) } override fun onAdShowedFullScreenContent() { Log.d(TAG, "Ad showed fullscreen content.") view?.findNavController()?.navigate(action) } } mInterstitialAd?.show(this.activity)} and It doesn't work. JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
In the latest implementation, you can listen to Interstitial ads via two callbacks. The first callback is for Ad loading, here you can check whether the Ad is successfully loaded or not. Once loaded, you can assign it to your local InterstitialAd variable, for example, mInterstitialAd and then you can show the Ad to the user. InterstitialAd.load(this,"ca-app-pub-3940256099942544/1033173712", adRequest, object : InterstitialAdLoadCallback() { override fun onAdFailedToLoad(adError: LoadAdError) { Log.d(TAG, adError?.message) mInterstitialAd = null } override fun onAdLoaded(interstitialAd: InterstitialAd) { Log.d(TAG, 'Ad was loaded.') mInterstitialAd = interstitialAd } }) The second callback can be used for recieving callbacks once the Ad is shown to user: mInterstitialAd?.fullScreenContentCallback = object: FullScreenContentCallback() { override fun onAdDismissedFullScreenContent() { Log.d(TAG, 'Ad was dismissed.') } override fun onAdFailedToShowFullScreenContent(adError: AdError?) { Log.d(TAG, 'Ad failed to show.') } override fun onAdShowedFullScreenContent() { Log.d(TAG, 'Ad showed fullscreen content.') mInterstitialAd = null; } } Now you can show the Ad: if (mInterstitialAd != null) { mInterstitialAd?.show(this) } else { Log.d("TAG", "The interstitial ad wasn't ready yet.") } Refer to https://developers.google.com/admob/android/interstitial?hl=en-US#load_an_ad for more details.

Related questions

0 votes
    I'm trying to show a LazyGrid of items within a main screen that has a scrollable content. I ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 3, 2022 in Education by JackTerrance
0 votes
    The ws-discovery specifications explains how to protect your network from message alteration Denial of service replay ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 11, 2022 in Education by JackTerrance
0 votes
    Your client noticed last month that his ad is often shown next to another advertiser's ad for the same search ... to other advertisers? Select the correct answer from above options...
asked Dec 1, 2021 in Education by JackTerrance
0 votes
    I'm trying to do the Udacity mini project and I've got the latest version of the SKLearn library ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 24, 2022 in Education by JackTerrance
0 votes
    int fun(int n) { if(n!=0) { return n – fun(n-5); } else { return n; } } int main(){ int n = 20, z; z = fun(n); printf(“%d”, z); } Select the correct answer from above options...
asked Dec 31, 2021 in Education by JackTerrance
0 votes
    What would be the network address of the IP address 20.12.180.17 with subnet mask 255.255.255.224? 20.12.180. ... .192 255.12.180.224 Select the correct answer from above options...
asked Dec 24, 2021 in Education by JackTerrance
0 votes
    Plz write a program for the following pattern in Java class 10 ICSE 2 6 12 20 30 42 4 6 8 10 12 2 2 2 ... spam. Answer only if you know Select the correct answer from above options...
asked Nov 30, 2021 in Education by JackTerrance
0 votes
    m 1) Int a=0.b=20; for (int i=20;i>=4;i=i-3) { if(i%21=0 a=a+2; ) b=b+a: predict the value of b after execution Select the correct answer from above options...
asked Nov 27, 2021 in Education by JackTerrance
0 votes
    Int a=0.b=20: for (int i=20:i>=4:i=i-3) { if(i%2!=0) a=a+2: 3 b=b+a: . Select the correct answer from above options...
asked Nov 27, 2021 in Education by JackTerrance
0 votes
    The probability that the graph of y=16x2+8(a+5)x-7a-5=0, is strictly above the x-axis, If a∈[-20,0] A. 1720 B. 1320 C. 720 D. 320 Select the correct answer from above options...
asked Nov 15, 2021 in Education by JackTerrance
0 votes
    Find the electric field of a potential function given by 20 log x + y at the point (1 ... theory proposed by,electromagnetic theory engineering physics,electromagnetic theory nptel...
asked Nov 11, 2021 in Education by JackTerrance
...