public override void Init()
    {
        if (!IsInit)
        {
            IsInit = true;

            interstitial = new InterstitialAd(UnitId);

            // Called when an ad request has successfully loaded.
            interstitial.OnAdLoaded += HandleOnAdLoaded;
            // Called when an ad request failed to load.
            interstitial.OnAdFailedToLoad += HandleOnAdFailedToLoad;
            // Called when an ad is shown.
            interstitial.OnAdOpening += HandleOnAdOpened;
            // Called when the ad is closed.
            interstitial.OnAdClosed += HandleOnAdClosed;
        }

        // Create an empty ad request.
        var builder = new AdRequest.Builder();
        var request = builder.Build();

        // Load the banner with the request.
        interstitial.LoadAd(request);
    }
예제 #2
0
        public void LoadRewardedVideo(string adUnit)
        {
            if (_rewardedAds == null)
            {
                CreateRewardedVideo();
            }

            if (!_rewardedAds.IsLoaded)
            {
                var requestBuilder = new AdRequest.Builder();

                if (CrossMTAdmob.Current.TestDevices != null)
                {
                    foreach (var testDevice in CrossMTAdmob.Current.TestDevices)
                    {
                        requestBuilder.AddTestDevice(testDevice);
                    }
                }

                _rewardedAds.LoadAd(adUnit, requestBuilder.Build());
            }
            else
            {
                Console.WriteLine("Rewarded Video already loaded");
            }
        }
예제 #3
0
        public void LoadInterstitial(string adUnit)
        {
            if (_ad == null || _ad?.AdUnitId != adUnit)
            {
                CreateInterstitialAd(adUnit);
            }

            if (!_ad.IsLoaded && !_ad.IsLoading)
            {
                var requestBuilder = new AdRequest.Builder();

                if (CrossMTAdmob.Current.TestDevices != null)
                {
                    foreach (var testDevice in CrossMTAdmob.Current.TestDevices)
                    {
                        requestBuilder.AddTestDevice(testDevice);
                    }
                }

                _ad.LoadAd(requestBuilder.Build());
            }
            else
            {
                Console.WriteLine("Interstitial already loaded");
            }
        }
예제 #4
0
        private AdView CreateNativeAdControl()
        {
            if (_adView != null)
            {
                return(_adView);
            }

            // This is a string in the Resources/values/strings.xml that I added or you can modify it here. This comes from admob and contains a / in it
            //adUnitId = Forms.Context.Resources.GetString(Resource.String.banner_ad_unit_id);

            _adView          = new AdView(Android.App.Application.Context);
            _adView.AdSize   = _adSize;
            _adView.AdUnitId = _adUnitId;

            var adParams = new LinearLayout.LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent);

            _adView.LayoutParameters = adParams;

            var builder = new AdRequest.Builder();

#if DEBUG
            builder.AddTestDevice("9E07835511290AFB8BC1953CCF608168");
#endif
            _adView.LoadAd(builder.Build());

            return(_adView);
        }
        void LoadAd()
        {
            var requestbuilder = new AdRequest.Builder();

            interstitialAd.LoadAd(requestbuilder.Build());
            interstitialAd.AdListener = new AdListener(Android.App.Application.Context, interstitialAd);
        }
예제 #6
0
        AdView CreateNativeControl()
        {
            if (adView != null)
            {
                return(adView);
            }

            adUnitId        = "ca-app-pub-5416107198862625/5844787393";//Forms.Context.Resources.GetString(5844787393);
            adView          = new AdView(Forms.Context);
            adView.AdSize   = adSize;
            adView.AdUnitId = adUnitId;

            var adParams = new LinearLayout.LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent);

            adView.LayoutParameters = adParams;

            var builder = new AdRequest.Builder();

#if DEBUG
            builder.AddTestDevice(AdRequest.DeviceIdEmulator);
            builder.AddTestDevice("5DB4DF7E7BA21D9E1B65423CE5A580E5");
#else
            adView.LoadAd(builder.Build());
#endif
            return(adView);
        }
예제 #7
0
        /// <summary>
        /// Request for load ad
        /// </summary>
        private void Request()
        {
            var builder = new AdRequest.Builder();

            if (IsTest)
            {
                builder
                .AddTestDevice(AdRequest.TestDeviceSimulator)
                .AddTestDevice(UniqueID);
            }

            var adRequest = builder.Build();

            switch (AdType)
            {
            case AdType.RewardVideoAd:
                rewardedAd.LoadAd(adRequest);
                break;

            case AdType.BannerView:
                bannerView.LoadAd(adRequest);
                break;

            case AdType.InterstitialAd:
                interstitialAd.LoadAd(adRequest);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
예제 #8
0
        public static AdRequest BuildAdRequest()
        {
            var builder = new AdRequest.Builder();

            foreach (var deviceId in  UM_GoogleAdsSettings.Instance.TestDevices)
            {
                builder.AddTestDevice(deviceId);
            }

            foreach (var keyword in UM_GoogleAdsSettings.Instance.Keywords)
            {
                builder.AddKeyword(keyword);
            }

            builder.TagForChildDirectedTreatment(UM_GoogleAdsSettings.Instance.TagForChildDirectedTreatment);


            if (UM_GoogleAdsSettings.Instance.NPA)
            {
                builder.AddExtra("npa", "1");
            }

            if (UM_GoogleAdsSettings.Instance.Gender != Gender.Unknown)
            {
                builder.SetGender(UM_GoogleAdsSettings.Instance.Gender);
            }

            if (UM_GoogleAdsSettings.Instance.Birthday != DateTime.MinValue)
            {
                builder.SetBirthday(UM_GoogleAdsSettings.Instance.Birthday);
            }

            return(builder.Build());
        }
예제 #9
0
    private void RequestRewardBasedVideo()
    {
        Debug.Log("RequestRewardBasedVideo start");
        if (!string.IsNullOrEmpty(this.unitId))
        {
            if (this.rewardBasedVideo == null)
            {
                this.rewardBasedVideo = RewardBasedVideoAd.Instance;
                // Called when the user should be rewarded for watching a video.
                this.rewardBasedVideo.OnAdRewarded += this.HandleRewardBasedVideoRewarded;
                // Called when the ad is closed.
                rewardBasedVideo.OnAdClosed       += HandleRewardBasedVideoClosed;
                rewardBasedVideo.OnAdLoaded       += HandleRewardBasedVideoLoaded;
                rewardBasedVideo.OnAdFailedToLoad += HandleRewardBasedVideoFailLoaded;
            }

            AdRequest.Builder _builder = new AdRequest.Builder();

            if (Debug.isDebugBuild)
            {
                _builder.AddTestDevice(AdCommon.DeviceIdForAdmob);
            }
            if (IsTest)
            {
                _builder.AddTestDevice(AdCommon.DeviceIdForAdmob);
            }

            // Load the rewarded video ad with the request.
            this.rewardBasedVideo.LoadAd(_builder.Build(), unitId);

            Debug.Log("RequestRewardBasedVideo Done");
        }
    }
        public static AdRequest GetRequest()
        {
            UpdateRequestConfiguration();

            bool   addExtra       = false;
            Bundle bundleExtra    = new Bundle();
            var    requestBuilder = new AdRequest.Builder();

            if (!CrossAdMob.Current.UserPersonalizedAds)
            {
                bundleExtra.PutString("npa", "1");
                addExtra = true;
            }
            if (CrossAdMob.Current.UseRestrictedDataProcessing)
            {
                bundleExtra.PutString("rdp", "1");
                addExtra = true;
            }
            if (CrossAdMob.Current.CustomParameters.Count > 0)
            {
                foreach (KeyValuePair <string, string> param in CrossAdMob.Current.CustomParameters)
                {
                    bundleExtra.PutString(param.Key, param.Value);
                }
                addExtra = true;
            }

            if (addExtra)
            {
                requestBuilder = requestBuilder.AddNetworkExtrasBundle(Java.Lang.Class.FromType(typeof(AdMobAdapter)), bundleExtra);
            }

            return(requestBuilder.Build());
        }
    public override void Init()
    {
        if (!IsInit)
        {
            IsInit = true;

            rewardedAd = new RewardedAd(UnitId);

            // Called when an ad request has successfully loaded.
            rewardedAd.OnAdLoaded += HandleOnAdLoaded;
            // Called when an ad request failed to load.
            rewardedAd.OnAdFailedToLoad += HandleRewardBasedVideoFailedToLoad;
            // Called when an ad is shown.
            rewardedAd.OnAdOpening += HandleRewardBasedVideoStarted;
            // Called when an ad request failed to show.
            rewardedAd.OnAdFailedToShow += HandleRewardBasedVideoFailedToShow;
            // Called when the user should be rewarded for interacting with the ad.
            rewardedAd.OnUserEarnedReward += HandleRewardBasedVideoRewarded;
            // Called when the ad is closed.
            rewardedAd.OnAdClosed += HandleOnAdClosed;
        }

        // Create an empty ad request.
        var builder = new AdRequest.Builder();
        var request = builder.Build();

        // Load the banner with the request.
        rewardedAd.LoadAd(request);
    }
예제 #12
0
    private void RequestBanner()
    {
        if (!string.IsNullOrEmpty(this.unitId))
        {
            if (this.bannerView != null)
            {
                this.bannerView.Destroy();
                this.bannerView = null;
            }
            MobileAds.Initialize(initStatus => {});
            this.bannerView = new BannerView(this.unitId, this.adSize[this.GoogleSize], this.GooglePosition);
            // Called when an ad request has successfully loaded.
            this.bannerView.OnAdLoaded += this.HandleOnAdLoaded;

            AdRequest.Builder _builder = new AdRequest.Builder();

            if (Debug.isDebugBuild)
            {
                _builder.AddTestDevice(AdCommon.DeviceIdForAdmob);
            }
            if (IsTest)
            {
                _builder.AddTestDevice(AdCommon.DeviceIdForAdmob);
            }

            this.bannerView.LoadAd(_builder.Build());
        }
    }
예제 #13
0
        public static AdView CustomBuild(this AdView ad)
        {
            var requestBuilder = new AdRequest.Builder();

            ad.LoadAd(requestBuilder.Build());
            return(ad);
        }
    public static void RequestInterstitial(string BannerAdUnitID, string[] TestDeviceIDs, bool showOnLoad)
    {
        interstitialShowOnLoad = showOnLoad;
                #if UNITY_ANDROID
        string adUnitId = BannerAdUnitID;
                #elif UNITY_IPHONE
        string adUnitId = BannerAdUnitID;
                #else
        string adUnitId = "unexpected_platform";
                #endif

        //Initialize an InterstitialAd.
        interstitial = new InterstitialAd(adUnitId);

        //Register call back
        interstitial.OnAdLoaded += OnInterstitialLoaded;

        // Create interstitial ad request.
        AdRequest.Builder adBuilder = new AdRequest.Builder();

        for (int i = 0; i < TestDeviceIDs.Length; i++)
        {
            adBuilder.AddTestDevice(TestDeviceIDs[i]);
        }

        i_request = adBuilder.Build();

        // Load the interstitial with the request.
        interstitial.LoadAd(i_request);
    }
예제 #15
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            if (view != null)
            {
                return(view);
            }

            view          = inflater.Inflate(Resource.Layout.Investment, container, false);
            listViewEntry = view.FindViewById <ListView>(Resource.Id.listData);
            listViewEntry.ItemSelected += (object sender, AdapterView.ItemSelectedEventArgs e) => {
            };
            RegisterForContextMenu(listViewEntry);

            txtSearch              = view.FindViewById <EditText>(Resource.Id.txtSearch);
            txtSearch.TextChanged += txtSearch_TextChanged;

            LinearLayout linearAdmob = view.FindViewById <LinearLayout>(Resource.Id.linearAdmob);
            var          ad          = new AdView(ParentContext);

            ad.AdSize   = AdSize.SmartBanner;
            ad.AdUnitId = "ca-app-pub-5961528798514575/2983423449";
            var requestbuilder = new AdRequest.Builder();

            ad.LoadAd(requestbuilder.Build());
            linearAdmob.AddView(ad);

            return(view);
        }
예제 #16
0
파일: AdsGoogle.cs 프로젝트: surnek/tm-15v
        public static void InitAdView(AdView mAdView, RecyclerView mRecycler)
        {
            try
            {
                var isPro = ListUtils.MyUserInfoList.FirstOrDefault()?.IsPro ?? 0;
                if (isPro == 0 && AppSettings.ShowAdMobBanner)
                {
                    if (mAdView != null)
                    {
                        mAdView.Visibility = ViewStates.Visible;
                        var adRequest = new AdRequest.Builder();
                        adRequest.AddTestDevice(UserDetails.AndroidId);
                        mAdView.LoadAd(adRequest.Build());
                        mAdView.AdListener = new MyAdListener(mAdView, mRecycler);
                    }
                }
                else
                {
                    if (mAdView != null)
                    {
                        mAdView.Pause();
                        mAdView.Visibility = ViewStates.Gone;
                    }

                    Methods.SetMargin(mRecycler, 5, 0, 0, 0);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
예제 #17
0
        protected override AdView CreateNativeControl()
        {
            if (adView != null)
            {
                return(adView);
            }

            //adView = new AdView(Forms.Context);
            //adView.AdSize = AdSize.SmartBanner;
            //adView.AdUnitId = adUnitId;

            //var adParams = new LinearLayout.LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent);

            //adView.LayoutParameters = adParams;

            //adView.LoadAd(new AdRequest
            //				.Builder()
            //				.Build());

            adView          = new AdView(Forms.Context);
            adView.AdSize   = AdSize.SmartBanner;
            adView.AdUnitId = adUnitId;

            var requestbuilder = new AdRequest.Builder();

            adView.LoadAd(requestbuilder.Build());

            return(adView);
        }
예제 #18
0
    public void requestBanner()
    {
                #if UNITY_EDITOR
        string adUnitId = "unused";
                #elif UNITY_ANDROID
        string adUnitId = "ca-app-pub-3490576924828867/9637786031";
                #elif UNITY_IPHONE
        string adUnitId = "unused";
                #else
        string adUnitId = "unexpected_platform";
                #endif

        BannerView        bannerView = new BannerView(adUnitId, AdSize.Banner, AdPosition.Bottom);
        AdRequest.Builder builder    = new AdRequest.Builder();
        if (Debug.isDebugBuild)
        {
            AdRequest request = builder.AddTestDevice("atestdevice").Build();
            bannerView.LoadAd(request);
        }
        else
        {
            AdRequest request = builder.Build();
            bannerView.LoadAd(request);
        }

        bannerView.Show();
    }
예제 #19
0
        public static AdRequest BuildRequest(TDAdConfig data)
        {
            var builder = new AdRequest.Builder();

            if (m_Config.isDebugMode)
            {
                builder.AddTestDevice("54A21F94407E31BD8A20879613096F8B");
            }

            if (!string.IsNullOrEmpty(data.keyword))
            {
                builder.AddKeyword(data.keyword);
            }
            builder.SetGender((Gender)data.gender);
            if (data.isBirthDayConfiged)
            {
                builder.SetBirthday(data.GetBirthDayTime());
            }

            if (data.forFamilies)
            {
                builder.AddExtra("is_designed_for_families", "true");
            }

            if (data.forChild)
            {
                builder.TagForChildDirectedTreatment(true);
            }

            return(builder.Build());
        }
예제 #20
0
        protected override void OnElementChanged(ElementChangedEventArgs <View> e)
        {
            base.OnElementChanged(e);

            if (Control != null)
            {
                return;
            }

            var adMobElement = Element as InAppAdView;

            if (adMobElement == null)
            {
                return;
            }

            var ad = new AdView(Forms.Context);

            ad.AdSize   = AdSize.Banner;
            ad.AdUnitId = adMobElement.AdUnitId;

            var requestbuilder = new AdRequest.Builder();

            ad.LoadAd(requestbuilder.Build());

            SetNativeControl(ad);
        }
예제 #21
0
    private void ReRequestInterstitial()
    {
        if (!string.IsNullOrEmpty(this.unitId))
        {
            if (this.interstitialAd != null)
            {
                this.interstitialAd.Destroy();
                this.interstitialAd = null;
            }

            this.interstitialAd = new InterstitialAd(this.unitId);

            // Called when the ad is closed.
            this.interstitialAd.OnAdClosed += this.HandleOnAdClosed;
            this.interstitialAd.OnAdLoaded += this.HandleOnAdLoaded;

            AdRequest.Builder _builder = new AdRequest.Builder();

            if (Debug.isDebugBuild)
            {
                _builder.AddTestDevice(AdCommon.DeviceIdForAdmob);
            }
            if (IsTest)
            {
                _builder.AddTestDevice(AdCommon.DeviceIdForAdmob);
            }

            this.interstitialAd.LoadAd(_builder.Build());
        }
    }
예제 #22
0
        public static void InitAdView(AdView mAdView, RecyclerView mRecycler)
        {
            try
            {
                if (mAdView == null)
                {
                    return;
                }

                if (AppSettings.ShowAdMobBanner)
                {
                    mAdView.Visibility = ViewStates.Visible;
                    var adRequest = new AdRequest.Builder();
                    adRequest.AddTestDevice(UserDetails.AndroidId);
                    mAdView.LoadAd(adRequest.Build());
                    mAdView.AdListener = new MyAdListener(mAdView, mRecycler);
                }
                else
                {
                    mAdView.Pause();
                    mAdView.Visibility = ViewStates.Gone;
                    if (mRecycler != null)
                    {
                        Methods.SetMargin(mRecycler, 0, 0, 0, 0);
                    }
                }
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
예제 #23
0
        public async Task ActivateAd(LinearLayout adbox)
        {
            try
            {
                if (!AppStats.Current.AdShows)
                {
                    return;
                }

                Context context = adbox.Context;
                {
                    ad        = new AdView(context);
                    ad.AdSize = AdSize.SmartBanner;
#if V16
                    ad.AdUnitId = "ca-app-pub-3167302081266616/8994125881";
#else
                    ad.AdUnitId = "ca-app-pub-3167302081266616/3848015885";
#endif
                    var requestbuilder = new AdRequest.Builder();
                    ad.LoadAd(requestbuilder.Build());
                }

                adbox.AddView(ad);
            }
            catch (Exception ex)
            {
                LittleWatson.ReportException(ex);
            }
        }
        public static InterstitialAd CustomBuild(this InterstitialAd ad)
        {
            var requestbuilder = new AdRequest.Builder();

            ad.LoadAd(requestbuilder.Build());
            return(ad);
        }
예제 #25
0
        protected override void OnElementChanged(ElementChangedEventArgs <View> e)
        {
            base.OnElementChanged(e);

            if (Control == null)
            {
                var ad = new AdView(Context)
                {
                    AdSize = AdSize.SmartBanner,

                    // DEBUG CHANGE!
                    //AdUnitId = PrivateKeys.AdmobBannerTestId
                    AdUnitId = PrivateKeys.AdmobBannerId
                };

                var requestbuilder = new AdRequest.Builder();


                ad.LoadAd(requestbuilder.Build());
                e.NewElement.HeightRequest = GetSmartBannerDpHeight();


                SetNativeControl(ad);
            }
        }
예제 #26
0
        /// <summary>
        /// reload the view and hit up google admob
        /// </summary>
        /// <param name="e"></param>
        protected override void OnElementChanged(ElementChangedEventArgs <View> e)
        {
            base.OnElementChanged(e);

            //convert the element to the control we want
            var adMobElement = Element as AdMobBuddyControl;

            if ((adMobElement != null) && (e.OldElement == null))
            {
                AdView ad = new AdView(this.Context);
                ad.AdSize   = AdSize.Banner;
                ad.AdUnitId = adMobElement.AdUnitId;
                var request = new AdRequest.Builder();
#if DEBUG
                var identifier    = Android.Provider.Settings.Secure.GetString(_context.ContentResolver, Android.Provider.Settings.Secure.AndroidId);
                var currentDevice = MD5.GetMd5String(identifier).ToUpper();
                if (!ApiConstants.GoogleAds.Devices.Contains(currentDevice))
                {
                    ApiConstants.GoogleAds.Devices.Add(currentDevice);
                }

                foreach (var device in ApiConstants.GoogleAds.Devices)
                {
                    request.AddTestDevice(device);
                }
                request.AddTestDevice(AdRequest.DeviceIdEmulator);
#endif
                ad.LoadAd(request.Build());
                this.SetNativeControl(ad);
            }
        }
        public Task Display(string AdId)
        {
            var            displyTask     = new TaskCompletionSource <bool>();
            InterstitialAd AdInterstitial = new InterstitialAd(context: Forms.Context)
            {
                AdUnitId = AdId
            };

            {
                var adInterstitialListener = new AdInterstitialListener(AdInterstitial)
                {
                    AdClosed = () =>
                    {
                        if (displyTask != null)
                        {
                            displyTask.TrySetResult(AdInterstitial.IsLoaded);
                            displyTask = null;
                        }
                    },
                    AdFailed = () =>
                    {
                        if (displyTask != null)
                        {
                            displyTask.TrySetResult(AdInterstitial.IsLoaded);
                            displyTask = null;
                        }
                    }
                };
                AdRequest.Builder RequestBuilder = new AdRequest.Builder();
                AdInterstitial.AdListener = adInterstitialListener;
                AdInterstitial.LoadAd(RequestBuilder.Build());
            }
            return(Task.WhenAll(displyTask.Task));
        }
예제 #28
0
        protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.View> e)
        {
            base.OnElementChanged(e);

            var adLoader = new AdLoader.Builder(Context, AppConfig.ADMOB_NATIVE_ADS_ID);

            var listener = new UnifiedNativeAdLoadedListener();

            listener.OnNativeAdLoaded += (s, ad) =>
            {
                // Load ad Completed
                try
                {
                    ButtonColor = (e.NewElement as AdmobSmallNativeAdsView).ButtonColor.ToAndroid();
                    nativeAd    = ad;
                    var root     = new UnifiedNativeAdView(Context);
                    var inflater = (LayoutInflater)Context.GetSystemService(Context.LayoutInflaterService);

                    var nativeAdView = (UnifiedNativeAdView)inflater.Inflate(Resource.Layout.gnt_small_template_view, root);

                    populateUnifiedNativeAdView(ad, nativeAdView);
                    SetNativeControl(nativeAdView);
                }
                catch
                {
                }
            };

            adLoader.ForUnifiedNativeAd(listener);
            var requestBuilder = new AdRequest.Builder();

            adLoader.Build().LoadAd(requestBuilder.Build());
        }
예제 #29
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            if (view != null)
            {
                return(view);
            }

            view = inflater.Inflate(Resource.Layout.Stat, container, false);

            listViewType = view.FindViewById <ListView>(Resource.Id.listTypes);
            listViewType.ItemSelected += listViewType_ItemSelected;
            listViewType.ItemClick    += listViewType_ItemClick;

            LinearLayout linearAdmob = view.FindViewById <LinearLayout>(Resource.Id.linearAdmob);
            var          ad          = new AdView(ParentContext);

            ad.AdSize   = AdSize.SmartBanner;
            ad.AdUnitId = "ca-app-pub-5961528798514575/1367089442";
            var requestbuilder = new AdRequest.Builder();

            ad.LoadAd(requestbuilder.Build());
            linearAdmob.AddView(ad);

            return(view);
        }
예제 #30
0
            public void OnRewardedVideoAdLoaded( )
            {
                string android_id     = Android.Provider.Settings.Secure.GetString(Application.Context.ContentResolver, Android.Provider.Settings.Secure.AndroidId);
                var    requestbuilder = new AdRequest.Builder();

                requestbuilder.AddTestDevice(android_id);
                Rad.LoadAd(AppSettings.Ad_RewardVideo_Key, requestbuilder.Build());
                Rad.Show();
            }
예제 #31
0
        public static AdRequest GetAdRequest (bool addTestDevice)
        {
            var testDeviceId = "BC2508B19A2078B6AC72133BB7E6E177";
            var builder = new AdRequest.Builder ();

            if (addTestDevice)
                builder.AddTestDevice (testDeviceId);

            return builder.Build ();
        }
        public static AdRequest GetAdRequest (bool addTestDevice)
        {
            var testDeviceId = "9CCC83D186F2A2DF954788ACE76F5F41";
            var builder = new AdRequest.Builder ();

            if (addTestDevice)
                builder.AddTestDevice (testDeviceId);

            return builder.Build ();
        }
예제 #33
0
        public void Show(string adUnit)
        {                        
            var context = Application.Context;
            _ad = new InterstitialAd(context);
            _ad.AdUnitId = adUnit;

            var intlistener = new InterstitialAdListener(_ad);
            intlistener.OnAdLoaded();
            _ad.AdListener = intlistener;

            var requestbuilder = new AdRequest.Builder();
            _ad.LoadAd(requestbuilder.Build());
        }
        protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.View> e)
        {
            base.OnElementChanged(e);
            if (Control == null)
            {
                var adsbanner = (AdBanner)Element;
                var adview = new AdView(Context);
                adview.AdSize = AdSize.Banner;
                adview.AdUnitId = adsbanner.AdID;
                var requestbuilder = new AdRequest.Builder();
                adview.LoadAd(requestbuilder.Build());
                base.SetNativeControl(adview);
            }

        }
예제 #35
0
        /// <summary>
        /// reload the view and hit up google admob 
        /// </summary>
        /// <param name="e"></param>
        protected override void OnElementChanged(ElementChangedEventArgs<View> e)
        {
            base.OnElementChanged(e);

            //convert the element to the control we want
            var adMobElement = Element as AdmobBannerView;

            if ((adMobElement != null) && (e.OldElement == null))
            {
                var ad = new AdView(Context);
                ad.AdSize = AdSize.Banner;
                ad.AdUnitId = adMobElement.AdUnitID;
                var requestbuilder = new AdRequest.Builder();
                ad.LoadAd(requestbuilder.Build());
                SetNativeControl(ad);
            }
        }
		public static InterstitialAd CustomBuild(this InterstitialAd ad)
		{
			var requestbuilder = new AdRequest.Builder();
			ad.LoadAd(requestbuilder.Build());
			return ad;
		}
		public static AdView CustomBuild(this AdView ad)
		{
			var requestbuilder = new AdRequest.Builder();
			ad.LoadAd(requestbuilder.Build());
			return ad;
		}