public void ShowAd() { var context = Android.App.Application.Context; interstitialAd = new InterstitialAd(context); interstitialAd.AdUnitId = adUnit; var intlistener = new InterstitialListener(interstitialAd); intlistener.OnAdLoaded(); interstitialAd.AdListener = intlistener; var requestBuilder = new AdRequest.Builder(); location = new Location("HARDCODED"); location.Latitude = 53.349804; location.Longitude = -6.260310; requestBuilder.SetLocation(location); interstitialAd.LoadAd(requestBuilder.Build()); }
AdRequest GetRequest(Dictionary <string, string> advertisingTargetInfo) { var request = new AdRequest.Builder(); request.AddTestDevice(AdRequest.DeviceIdEmulator); request.AddTestDevice("260661DE96DFEDE845160916AD01F3CA"); //samsung tablet //Gender var gender = Gender.Unknown; if (advertisingTargetInfo.ContainsKey(AdKeyGender)) { gender = advertisingTargetInfo[AdKeyGender].Equals("female", StringComparison.InvariantCultureIgnoreCase) ? Gender.Female : Gender.Male; request.SetGender((int)gender); } //Location var location = RealmServices.GetLastUserLocation(); if (location != null) { var loc = new Android.Locations.Location(""); loc.Latitude = location.Latitude; loc.Longitude = location.Longitude; loc.Accuracy = 1; request.SetLocation(loc); } //Birthday if (advertisingTargetInfo.ContainsKey(AdKeyBirthday)) { var birthday = DateTime.ParseExact(advertisingTargetInfo[AdKeyBirthday], "MM/dd/yyyy", null); var bith = new Java.Util.Date(birthday.Year, birthday.Month, birthday.Day); request.SetBirthday(bith); } return(request.Build()); }