Exemple #1
0
            public void ShowAd(Activity context, TemplateView template = null)
            {
                try
                {
                    Context = context;

                    Template            = template ?? Context.FindViewById <TemplateView>(Resource.Id.my_template);
                    Template.Visibility = ViewStates.Gone;

                    if (AppSettings.ShowAdMobNative)
                    {
                        AdLoader.Builder builder = new AdLoader.Builder(Context, AppSettings.AdAdMobNativeKey);
                        builder.ForUnifiedNativeAd(this);
                        VideoOptions videoOptions = new VideoOptions.Builder()
                                                    .SetStartMuted(true)
                                                    .Build();
                        NativeAdOptions adOptions = new NativeAdOptions.Builder()
                                                    .SetVideoOptions(videoOptions)
                                                    .Build();

                        builder.WithNativeAdOptions(adOptions);

                        AdLoader adLoader = builder.WithAdListener(new AdListener()).Build();
                        adLoader.LoadAd(new AdRequest.Builder().Build());
                    }
                    else
                    {
                        Template.Visibility = ViewStates.Gone;
                    }
                }
                catch (Exception e)
                {
                    Methods.DisplayReportResultTrack(e);
                }
            }
Exemple #2
0
        private void BindAdMob(Holders.AdMobAdapterViewHolder holder)
        {
            try
            {
                Template = holder.MianAlert;

                AdLoader.Builder builder = new AdLoader.Builder(holder.MainView.Context, AppSettings.AdAdMobNativeKey);
                builder.ForUnifiedNativeAd(this);

                VideoOptions videoOptions = new VideoOptions.Builder()
                                            .SetStartMuted(true)
                                            .Build();

                NativeAdOptions adOptions = new NativeAdOptions.Builder()
                                            .SetVideoOptions(videoOptions)
                                            .Build();

                builder.WithNativeAdOptions(adOptions);

                AdLoader adLoader = builder.WithAdListener(new AdListener()).Build();
                adLoader.LoadAd(new AdRequest.Builder().Build());
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Exemple #3
0
            public void ShowAd(Activity context)
            {
                try
                {
                    Context             = context;
                    Template            = Context.FindViewById <TemplateView>(Resource.Id.my_template);
                    Template.Visibility = ViewStates.Gone;

                    var isPro = ListUtils.MyUserInfoList.FirstOrDefault()?.IsPro ?? 0;
                    if (isPro == 0 && AppSettings.ShowAdMobNative)
                    {
                        AdLoader.Builder builder = new AdLoader.Builder(Context, AppSettings.AdAdMobNativeKey);
                        builder.ForUnifiedNativeAd(this);
                        VideoOptions videoOptions = new VideoOptions.Builder()
                                                    .SetStartMuted(true)
                                                    .Build();
                        NativeAdOptions adOptions = new NativeAdOptions.Builder()
                                                    .SetVideoOptions(videoOptions)
                                                    .Build();

                        builder.WithNativeAdOptions(adOptions);

                        AdLoader adLoader = builder.WithAdListener(new AdListener()).Build();
                        adLoader.LoadAd(new AdRequest.Builder().Build());
                    }
                    else
                    {
                        Template.Visibility = ViewStates.Gone;
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            }
Exemple #4
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            SetContentView(Resource.Layout.activity_main);

            Android.Support.V7.Widget.Toolbar toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
            SetSupportActionBar(toolbar);
            ///Init ManagerAds
            adsMgr              = new AdsManager(ApplicationContext);
            txtStatusInter      = FindViewById <TextView>(Resource.Id.txtStateInterstitial);
            btnLoadInter        = FindViewById <Button>(Resource.Id.btnLoad);
            btnShowInter        = FindViewById <Button>(Resource.Id.btnShowInter);
            btnOpenActiveNative = FindViewById <Button>(Resource.Id.btnOpenNative);

            btnLoadInter.Click += BtnLoadInter_Click;
            btnShowInter.Click += BtnShowInter_Click;

            btnOpenActiveNative.Click += BtnOpenActiveNative_Click;

            //Implement Banner Ads
            var adview = FindViewById <AdView>(Resource.Id.adView);

            adsMgr.CreateAds(adview);

            var builder = new AdLoader.Builder(ApplicationContext, GetString(Resource.String.admobNative));
            var listen  = new AdsUnifiedLoadListening();

            listen.Ads_UnifiedNativeLoad += (obj, unifiedAds) =>
            {
                var          style = new NativeTemplateStyle.Builder().build();
                TemplateView view  = FindViewById <TemplateView>(Resource.Id.adviewTemplate);
                view.Visibility = ViewStates.Visible;
                view.SetStyles(style);
                view.SetNativeAd(unifiedAds);
            };
            builder.ForUnifiedNativeAd(listen);
            builder.WithAdListener(listen);
            builder.WithNativeAdOptions(new Android.Gms.Ads.Formats.NativeAdOptions.Builder().Build());

            AdLoader adloader = builder.Build();

            adloader.LoadAd(new AdRequest.Builder().Build());
            if (listen.Tag is null)
            {
                listen.Tag = adloader;
            }
        }
Exemple #5
0
        public void CreateUnifiedAds(int numAds, AdsUnifiedLoadListening listen)
        {
            if (listen == null)
            {
                throw new ValidatingException("Not Implemented listener Unified");
            }
            var builder = new AdLoader.Builder(context, context.GetString(Resource.String.admobNative));

            builder.ForUnifiedNativeAd(listen);
            builder.WithAdListener(listen);
            builder.WithNativeAdOptions(new Android.Gms.Ads.Formats.NativeAdOptions.Builder().SetAdChoicesPlacement(5).Build());

            AdLoader adloader = builder.Build();

            adloader.LoadAds(new AdRequest.Builder().Build(), numAds);
            if (listen.Tag is null)
            {
                listen.Tag = adloader;
            }
        }
Exemple #6
0
        public void Initialize()
        {
            if (Loader != null)
            {
                throw new InvalidOperationException("AdAgent.Initialize() should only be called once.");
            }

            var builder = new AdLoader.Builder(UIRuntime.CurrentActivity, UnitId);

            builder.ForUnifiedNativeAd(new UnifiedNativeAdListener(this));

            var adOptions = new NativeAdOptions.Builder()
                            .SetVideoOptions(new VideoOptions.Builder().SetStartMuted(true).Build())
                            .Build();

            builder.WithNativeAdOptions(adOptions);

            builder.WithAdListener(new ZebbleAdListener(this));

            Loader = builder.Build();
        }