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 think an Adlistener should do the trick.
Unfortunately, I have NO CLUE on how to implement it. Also, there is no tutorial on how to do it in C# only in Java and I couldn't find a translation for it :(
Add:
adListener.OnAdLoaded() += (o, e) =>
{
mInterstitialAd.Show();
};
This doesn't work :(
Any help would be awesome!
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
:
private class AdListener : Android.Gms.Ads.AdListener
{
private MainActivity that;
public AdListener(MainActivity t)
{
that = t;
}
public override void OnAdLoaded()
{
base.OnAdLoaded();
}
public override void OnAdClosed()
{
that.RequestNewInterstitial();
that.BeginSecondActivity();
}
}
You can also checked the official demo for xamarin android ad: AdMobExample Sample.