Xamarin,Android:使用AdListener权限 [英] Xamarin, Android: Using the AdListener right

查看:98
本文介绍了Xamarin,Android:使用AdListener权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在C#中使用AdListener。
应用程序首次启动时,我会插入一个插页式广告,但有时我的广告会因为未完全加载而被跳过。我认为Adlistener应该可以解决问题。

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.

不幸的是,我对如何实现它一无所知。此外,也没有关于如何仅使用Java在C#中进行操作的教程,我找不到它的翻译:(

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 :(

添加:

    adListener.OnAdLoaded() += (o, e) =>
    {
        mInterstitialAd.Show();
    };

这不起作用:(

任何帮助都会很棒!

推荐答案

您可以创建一个继承自 Android.Gms.Ads.AdListener ,然后使用此类的实例作为 mInterstitialAd 的侦听器,例如:

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();
    }
}

您还可以查看xamarin android ad的官方演示: AdMobExample示例

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

这篇关于Xamarin,Android:使用AdListener权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆