private void InitAdContainer() { ViewModelLocator.Settings.OnAdsMinutesPerDayChanged += SettingsOnOnAdsMinutesPerDayChanged; Bindings.Add(this.SetBinding(() => ViewModel.AdsContainerVisibility) .WhenSourceChanges(() => { if (ViewModel.AdsContainerVisibility) { if (!_initializedAds) { MobileAds.Initialize(ApplicationContext, "ca-app-pub-8220174765620095~3319675764"); var adRequest = new AdRequest.Builder().Build(); MainPageAdView.LoadAd(adRequest); _initializedAds = true; } MainPageAdView.Visibility = ViewStates.Visible; } else { MainPageAdView.Visibility = ViewStates.Gone; } })); _videoAd = MobileAds.GetRewardedVideoAdInstance(this); _videoAd.RewardedVideoAdListener = this; StartAdsTimeMeasurements(); }
private void SetUpViewAndAd() { if (view != null) { return; } view = new View(Xamarin.Forms.Forms.Context); var ad = MobileAds.GetRewardedVideoAdInstance(Xamarin.Forms.Forms.Context); ad.RewardedVideoAdListener = new RewardedVideoAdListener { Ad = ad }; ad.LoadAd("ca-app-pub-3940256099942544/5224354917", new AdRequest.Builder().Build()); ThreadPool.QueueUserWorkItem(s => { // Wait the ad to be loading. Thread.Sleep(20000); Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { if (ad.IsLoaded) { ad.Show(); } }); }); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_main); mAdView = FindViewById <AdView> (Resource.Id.adView); var adRequest = new AdRequest.Builder().Build(); mAdView.LoadAd(adRequest); mInterstitialAd = new InterstitialAd(this); mInterstitialAd.AdUnitId = GetString(Resource.String.test_interstitial_ad_unit_id); mInterstitialAd.AdListener = new AdListener(this); mLoadInterstitialButton = FindViewById <Button> (Resource.Id.load_interstitial_button); mLoadInterstitialButton.SetOnClickListener(new OnClickListener(this)); RewardedVideoAd = MobileAds.GetRewardedVideoAdInstance(this); RewardedVideoAd.RewardedVideoAdListener = this; LoadRewardedVideoAd(); DisplayVideoButton = FindViewById <Button>(Resource.Id.DisplayVideoButton); DisplayVideoButton.Click += (o, e) => { ShowRewardedVideo(); }; }
public AdMobAdapter(Activity activity, string appId, string interstitialAdID, string rewardedVideoAdID, string testDeviceID = "", bool childDirected = false) { _activity = activity; ChildDirected = childDirected; AppID = appId; InterstitialAdID = interstitialAdID; RewardedVideoAdID = rewardedVideoAdID; TestDeviceID = testDeviceID; MobileAds.Initialize(_activity, AppID); InterstitialAdHandler = new InterstitialAd(_activity); InterstitialAdHandler.AdUnitId = InterstitialAdID; interstitialListener = new InterstitialListener(this); InterstitialAdHandler.AdListener = interstitialListener; RewardedVideoAdHandler = MobileAds.GetRewardedVideoAdInstance(_activity); RewardedVideoAdHandler.UserId = AppID; videoRewardedListener = new RewardedVideoListener(this); RewardedVideoAdHandler.RewardedVideoAdListener = videoRewardedListener; videoRewardedListener.OnVideoReward += VideoReward; LoadInterstitialAd(); LoadRewardedVideoAd(); }
public AdInterstitial_Droid() { RewardedVideoAd = MobileAds.GetRewardedVideoAdInstance(Android.App.Application.Context); RewardedVideoAd.RewardedVideoAdListener = this; //RewardedVideoAd.AdUnitId = "ca-app-pub-2667741859949498/7232000911"; LoadAd(); }
public RewardAd(Context context) { _rewardVideoAd = MobileAds.GetRewardedVideoAdInstance(context); _rewardVideoAd.RewardedVideoAdListener = this; _currentLoadsCount = 0; _completionSource = new TaskCompletionSource <RewardAdStatus>(); }
private void AdMobInitialization() { mInterstitialAd = new InterstitialAd(this); mInterstitialAd.AdUnitId = "ca-app-pub-8211072909515345/1856723600"; mInterstitialAd.AdListener = new AdListener(this); RewardedVideoAd = MobileAds.GetRewardedVideoAdInstance(this); RewardedVideoAd.RewardedVideoAdListener = this; LoadRewardedVideoAd(); }
private void LoadRewardedAd() { _rewardedVideoAd = MobileAds.GetRewardedVideoAdInstance(this); _rewardedVideoAd.RewardedVideoAdListener = this; //prod rewarded ad _rewardedVideoAd.LoadAd("ca-app-pub-7100837506775638/6637403349", new AdRequest.Builder().Build()); // test Adunit //_rewardedVideoAd.LoadAd("ca-app-pub-3940256099942544/5224354917", new AdRequest.Builder().Build()); }
public VideoActivity(Action onReward, Action onClose, Action onFailure, string adUnit) { this.onReward = onReward; this.onClose = onClose; this.onFailure = onFailure; rewardedVideoAd = MobileAds.GetRewardedVideoAdInstance(Android.App.Application.Context); var adRequest = new AdRequest.Builder().Build(); rewardedVideoAd.UserId = "pub-1711953563979738"; rewardedVideoAd.RewardedVideoAdListener = this; rewardedVideoAd.LoadAd(adUnit, adRequest); }
public void ShowAd(Context context) { try { // Use an activity context to get the rewarded video instance. Rad = MobileAds.GetRewardedVideoAdInstance(context); Rad.RewardedVideoAdListener = this; OnRewardedVideoAdLoaded(); } catch (Exception exception) { Console.WriteLine(exception); } }
public void ShowAd(Context context) { try { // Use an activity context to get the rewarded video instance. Rad = MobileAds.GetRewardedVideoAdInstance(context); Rad.UserId = context.GetString(Resource.String.admob_app_id); Rad.RewardedVideoAdListener = this; AdRequest adRequest = new AdRequest.Builder().Build(); Rad.LoadAd(AppSettings.AdRewardVideoKey, adRequest); } catch (Exception exception) { Methods.DisplayReportResultTrack(exception); } }
public void ShowAd(Context context) { try { MobileAds.Initialize(context, Settings.Ad_RewardVideo_Key); // Use an activity context to get the rewarded video instance. Rad = MobileAds.GetRewardedVideoAdInstance(context); Rad.RewardedVideoAdListener = this; OnRewardedVideoAdLoaded(); } catch (Exception exception) { Crashes.TrackError(exception); } }
private void CreateRewardedVideo() { var context = Application.Context; _rewardedAds = MobileAds.GetRewardedVideoAdInstance(context); var rewardListener = new MyRewardedVideoAdListener(); _rewardedAds.RewardedVideoAdListener = rewardListener; rewardListener.OnRewardedEvent += RewardListener_OnRewardedEvent; rewardListener.OnRewardedVideoAdClosedEvent += RewardListener_OnRewardedVideoAdClosedEvent; rewardListener.OnRewardedVideoAdFailedToLoadEvent += RewardListener_OnRewardedVideoAdFailedToLoadEvent; rewardListener.OnRewardedVideoAdLeftApplicationEvent += RewardListener_OnRewardedVideoAdLeftApplicationEvent; rewardListener.OnRewardedVideoAdLoadedEvent += RewardListener_OnRewardedVideoAdLoadedEvent; rewardListener.OnRewardedVideoAdOpenedEvent += RewardListener_OnRewardedVideoAdOpenedEvent; rewardListener.OnRewardedVideoStartedEvent += RewardListener_OnRewardedVideoStartedEvent; rewardListener.OnRewardedVideoCompletedEvent += RewardListener_OnRewardedVideoCompletedEvent; }
public AppSettings(Context context) { _context = context; GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DefaultSignIn).RequestEmail().Build(); _googleApiClient = new GoogleApiClient.Builder(_context) .AddApi(Auth.GOOGLE_SIGN_IN_API, gso) .AddScope(new Scope(Android.Gms.Common.Scopes.Profile)) .Build(); UserData.LoadApplicationSettings(this); MobileAds.Initialize(context, AdsApplicationIds); // Ads mRewardedVideoAd = MobileAds.GetRewardedVideoAdInstance(context); mRewardedVideoAd.RewardedVideoAdListener = new RewardedVideoAdListener(mRewardedVideoAd); Plugin.CurrentActivity.CrossCurrentActivity.Current.Activity = context as Activity; LocalMusicFolder = Path.Combine(Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryMusic).ToString(), "YoutubeManager"); Logger = new Logger(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal)); UserLocalSettings = FastDeepCloner.DeepCloner.CreateProxyInstance <LocalFileSettings>().ReadSettings(Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "Youtube.Manager.config")); UserDialogs.Init(context as MainActivity); // Media player CrossMediaManager.Current.Init(); }
public RewardedAd() { //Set the ad videoAd = MobileAds.GetRewardedVideoAdInstance(Android.App.Application.Context); }
public void Init(IAdsNotifty adsNotify) { _adsNotify = adsNotify; rewardedAd = MobileAds.GetRewardedVideoAdInstance(Android.App.Application.Context); rewardedAd.RewardedVideoAdListener = new AdRewardedView_Droid(_adsNotify); }
private void RewardVideoAdInitial() { SRRewardedVideoAd = MobileAds.GetRewardedVideoAdInstance(this); SRRewardedVideoAd.RewardedVideoAdListener = this; LoadRewardedVideoAd(); }