private void LoadAd() { Log.Info(TAG, "Start to load ad"); AdParam adParam = new AdParam.Builder().Build(); splashView = FindViewById <SplashView>(Resource.Id.splash_ad_view); splashView.SetAdDisplayListener(new SplashAdDisplayListeners()); Log.Info(TAG, "SplashView.SetAdDisplayListener function called successfully."); // Set a default app launch image. splashView.SetSloganResId(Resource.Drawable.default_slogan); Log.Info(TAG, "SplashView.SetSloganResId function called successfully."); splashView.SetWideSloganResId(Resource.Drawable.default_slogan); Log.Info(TAG, "SplashView.SetWideSloganResId function called successfully."); splashView.SetLogoResId(Resource.Mipmap.ic_launcher); Log.Info(TAG, "SplashView.SetLogoResId function called successfully."); // Set logo description. splashView.SetMediaNameResId(Resource.String.media_name); Log.Info(TAG, "SplashView.SetMediaNameResId function called successfully."); // Set the audio focus type for a video splash ad. splashView.SetAudioFocusType(AudioFocusType.NotGainAudioFocusWhenMute); Log.Info(TAG, "SplashView.SetAudioFocusType function called successfully."); SplashView.SplashAdLoadListener splashListener = new SplashListener(this); splashView.Load(GetString(Resource.String.ad_id_splash), (int)ScreenOrientation.Portrait, adParam, splashListener); Log.Info(TAG, "SplashView.Load function called successfully."); // Remove the timeout message from the message queue. timeoutHandler.RemoveMessages(MsgAdTimeout); // Send a delay message to ensure that the app home screen can be displayed when the ad display times out. timeoutHandler.SendEmptyMessageDelayed(MsgAdTimeout, AdTimeout); }
private void LoadBannerAd(int value) { Log.Debug(TAG, "Load banner ad, consent success: " + value); if (value == ConsentStatus.Unknown.Value) { RemoveBannerAd(); } // Obtain global ad singleton variables and add personalized ad request parameters. if (HwAds.RequestOptions == null) { requestOptions = new RequestOptions(); } else { requestOptions = HwAds.RequestOptions; } // For non-personalized ads, reset this parameter. requestOptions = requestOptions.ToBuilder() .SetTagForUnderAgeOfPromise((Java.Lang.Integer)UnderAge.PromiseTrue) .SetNonPersonalizedAd((Java.Lang.Integer)value) .Build(); HwAds.RequestOptions = requestOptions; AdParam adParam = new AdParam.Builder().Build(); adView.AdId = GetString(Resource.String.banner_ad_id); adView.BannerAdSize = BannerAdSize.BannerSizeSmart; adView.AdListener = new AdsListener(); adView.LoadAd(adParam); UpdateTextViewTips(value); }
public void LoadRewardAds() { RewardAd ad = new RewardAd(new Context(), "testx9dtjwj8hp"); AdParam adParam = new AdParam.Builder().build(); MRewardLoadListener rewardAdLoadListener = new MRewardLoadListener(ad); ad.loadAd(adParam, rewardAdLoadListener); }
public void LoadVideoAds() { InterstitialAd ad = new InterstitialAd(new Context()); ad.setAdId("testb4znbuh3n2"); ad.setAdListener(new MAdListener(ad)); AdParam.Builder builder = new AdParam.Builder(); ad.loadAd(builder.build()); }
public void LoadImageAds() { InterstitialAd ad = new InterstitialAd(new Context()); ad.setAdId("teste9ih9j0rc3"); ad.setAdListener(new MAdListener(ad)); AdParam.Builder builder = new AdParam.Builder(); AdParam adParam = builder.build(); ad.loadAd(adParam); }
/// <summary> /// Load the default banner ad. /// </summary> private void LoadDefaultBanner() { // Obtain BannerView based on the configuration in layout/activity_main.xml. defaultBannerView = FindViewById <BannerView>(Resource.Id.hw_banner_view); defaultBannerView.AdListener = new AdsListener(this); defaultBannerView.SetBannerRefresh(REFRESH_TIME); AdParam adParam = new AdParam.Builder().Build(); defaultBannerView.LoadAd(adParam); }
private void CreateNativeControl(AdBanner myMtAdView, string adsId, bool?personalizedAds) { if (_adView != null) { return; } _adUnitId = !string.IsNullOrEmpty(adsId) ? adsId : "testw6vs28auh3"; if (string.IsNullOrEmpty(_adUnitId)) { Console.WriteLine("You must set the adsID before using it"); } _adView = new BannerView(Context) { BannerAdSize = BannerAdSize.BannerSizeSmart, AdId = _adUnitId, LayoutParameters = new LinearLayout.LayoutParams(LayoutParams.MatchParent, LayoutParams.WrapContent) }; _adView.AdListener = new AdsListener(Context); AdParam adParam = new AdParam.Builder().Build(); _adView.SetBannerRefresh(REFRESH_TIME); _adView.LoadAd(adParam); }
private void LoadInterstitialAd() { interstitialAd = new InterstitialAd(this); interstitialAd.AdId = GetAdId(); Log.Info(TAG, "AdId has been successfully set."); interstitialAd.SetRewardAdListener(new RewardListener()); Log.Info(TAG, "SetRewardAdListener has been successfully set."); interstitialAd.AdListener = new AdsListener(this); Log.Info(TAG, "AdListener has been successfully set."); Log.Info(TAG, "AdId has been successfully get. AdId: " + interstitialAd.AdId); Log.Info(TAG, "AdListener has been successfully get. AdId: " + interstitialAd.AdListener); Log.Info(TAG, "IsLoaded: " + interstitialAd.IsLoaded); Log.Info(TAG, "IsLoading: " + interstitialAd.IsLoading); AdParam adParam = new AdParam.Builder().Build(); interstitialAd.LoadAd(adParam); Log.Info(TAG, "LoadAd function has been successfully set."); }
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); HwAds.Init(this); BannerView bannerView = FindViewById <BannerView>(Resource.Id.hw_banner_view); // Set the ad slot ID and ad size,"testw6vs28auh3" is a dedicated test ad slot ID. bannerView.AdId = "testw6vs28auh3"; bannerView.BannerAdSize = BannerAdSize.BannerSize32050; AdParam adParam = new AdParam.Builder().Build(); bannerView.LoadAd(adParam); FloatingActionButton fab = FindViewById <FloatingActionButton>(Resource.Id.fab); fab.Click += FabOnClick; }