Beispiel #1
0
        public static AdView InitAdView(Activity activity, LinearLayout adContainer, RecyclerView mRecycler)
        {
            try
            {
                if (AppSettings.ShowFbBannerAds)
                {
                    InitializeFacebook.Initialize(activity);

                    AdView adView = new AdView(activity, AppSettings.AdsFbBannerKey, AdSize.BannerHeight50);
                    // Add the ad view to your activity layout
                    adContainer.AddView(adView);

                    adView.SetAdListener(new BannerAdListener(adContainer, mRecycler));
                    // Request an ad
                    adView.LoadAd();

                    return(adView);
                }
                else
                {
                    adContainer.Visibility = ViewStates.Gone;
                }
                return(null);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(null);
            }
        }
Beispiel #2
0
        public static RewardedVideoAd InitRewardVideo(Activity activity)
        {
            try
            {
                if (AppSettings.ShowFbRewardVideoAds)
                {
                    if (CountRewarded == AppSettings.ShowAdMobRewardedVideoCount)
                    {
                        InitializeFacebook.Initialize(activity);

                        CountRewarded = 0;

                        var rewardVideoAd = new RewardedVideoAd(activity, AppSettings.AdsFbRewardVideoKey);

                        rewardVideoAd.SetAdListener(new MyRRewardVideoAdListener(activity, rewardVideoAd));
                        rewardVideoAd.LoadAd();
                        //RewardVideoAd.SetRewardData(new RewardData("YOUR_USER_ID", "YOUR_REWARD"));

                        return(rewardVideoAd);
                    }

                    CountRewarded++;
                }
                return(null);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(null);
            }
        }
Beispiel #3
0
        public static InterstitialAd InitInterstitial(Activity activity)
        {
            try
            {
                if (AppSettings.ShowFbInterstitialAds)
                {
                    if (CountInterstitial == AppSettings.ShowAdMobInterstitialCount)
                    {
                        InitializeFacebook.Initialize(activity);

                        CountInterstitial = 0;
                        var interstitialAd = new InterstitialAd(activity, AppSettings.AdsFbInterstitialKey);

                        interstitialAd.SetAdListener(new MyInterstitialAdListener(activity, interstitialAd));
                        // Request an ad
                        interstitialAd.LoadAd();

                        return(interstitialAd);
                    }

                    CountInterstitial++;
                }
                return(null);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(null);
            }
        }