Skip to content Skip to sidebar Skip to footer

Xamarin, Android: Using The Adlistener Right

I'm trying to use the AdListener in C#. I have an interstitial ad loading when the app is first started, but sometimes my ad gets skipped because it isn't fully loaded yet. I thin

Solution 1:

You can create a class which inherits from Android.Gms.Ads.AdListener, then use the instance of this class as the Listener for your mInterstitialAd, for example:

mInterstitialAd.AdListener = new AdListener(this);

AdListener:

privateclassAdListener : Android.Gms.Ads.AdListener
{
    private MainActivity that;

    publicAdListener(MainActivity t)
    {
        that = t;
    }

    publicoverridevoidOnAdLoaded()
    {
        base.OnAdLoaded();
    }

    publicoverridevoidOnAdClosed()
    {
        that.RequestNewInterstitial();
        that.BeginSecondActivity();
    }
}

You can also checked the official demo for xamarin android ad: AdMobExample Sample.

Post a Comment for "Xamarin, Android: Using The Adlistener Right"