示例#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);
                }
            }
示例#2
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);
                }
            }
示例#3
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);
            }
        }
示例#4
0
            public void ShowAd(Context context)
            {
                try
                {
                    //ca-app-pub-3940256099942544/2247696110
                    // Methods in the NativeAdOptions.Builder class can be
                    // used here to specify individual options settings.

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

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

                    adLoader = new AdLoader.Builder(context, Settings.Ad_Native_Key)
                               .ForAppInstallAd(this).ForContentAd(this).WithAdListener(this).WithNativeAdOptions(adOptions)
                               .Build();

                    var adRequest = new AdRequest.Builder().Build();
                    adLoader.LoadAd(adRequest);
                }
                catch (Exception exception)
                {
                    Crashes.TrackError(exception);
                }
            }