protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); // Get our button from the layout resource, // and attach an event to it Button button = FindViewById<Button>(Resource.Id.MyButton); button.Click += delegate { button.Text = string.Format("{0} clicks!", count++); }; //----------------------------------------------banner add stuff _bannerad = AdWrapper.ConstructStandardBanner(this, AdSize.SmartBanner, "your ad id here"); var listener = new admobDemo.adlistener(); listener.AdLoaded += () => { }; _bannerad.AdListener = listener; _bannerad.CustomBuild(); var layout = FindViewById<LinearLayout>(Resource.Id.mainlayout); layout.AddView(_bannerad); //------------------------------------------------------------- //-------------------------------------------------InterstitialAd stuff var FinalAd = AdWrapper.ConstructFullPageAdd(this, "your ad id here"); var intlistener = new admobDemo.adlistener(); intlistener.AdLoaded += () => { if (FinalAd.IsLoaded)FinalAd.Show(); }; FinalAd.AdListener = intlistener; FinalAd.CustomBuild(); //------------------------------------------------------------- }
// Constructor public MainPage() { InitializeComponent(); bannerAd = new AdView { Format = AdFormats.Banner, AdUnitID = "", Width = 320, Height = 50 }; //Set up delegates //Ad reception bannerAd.ReceivedAd += bannerAd_ReceivedAd; bannerAd.FailedToReceiveAd += bannerAd_FailedToReceiveAd; //Overlay bannerAd.DismissingOverlay += bannerAd_DismissingOverlay; bannerAd.ShowingOverlay += bannerAd_ShowingOverlay; //Application bannerAd.LeavingApplication += bannerAd_LeavingApplication; AdRequest adRequest = new AdRequest(); adRequest.ForceTesting = true; ContentPanel.Children.Add(bannerAd); bannerAd.LoadAd(adRequest); }
public static AdView ConstructStandardBanner(Context context, AdSize adSize, string UnitID) { var ad = new AdView(context); ad.AdSize = adSize; ad.AdUnitId = UnitID; return ad; }
void Awake () { // Create a banner's ad view with a unique placement ID (generate your own on the Facebook app settings). // Use different ID for each ad placement in your app. AdView adView = new AdView ("YOUR_PLACEMENT_ID", AdSize.BANNER_HEIGHT_50); this.adView = adView; this.adView.Register (this.gameObject); // Set delegates to get notified on changes or when the user interacts with the ad. this.adView.AdViewDidLoad = (delegate() { Debug.Log ("Ad view loaded."); this.adView.Show (100); }); adView.AdViewDidFailWithError = (delegate(string error) { Debug.Log ("Ad view failed to load with error: " + error); }); adView.AdViewWillLogImpression = (delegate() { Debug.Log ("Ad view logged impression."); }); adView.AdViewDidClick = (delegate() { Debug.Log ("Ad view clicked."); }); // Initiate a request to load an ad. adView.LoadAd (); }
void createBanner(int id, string unit_id) { try { Canvas layout = MainPage.getMainLayout(); if (layout != null) { Deployment.Current.Dispatcher.BeginInvoke(() => { try { AdView bannerAd = new AdView { Format = AdFormats.Banner, AdUnitID = unit_id }; AdRequest adRequest = new AdRequest(); layout.Children.Add(bannerAd); bannerAd.ReceivedAd += ReceivedAd; bannerAd.LoadAd(adRequest); bannerAd.Visibility = Visibility.Collapsed; _banners.Add(id, bannerAd); } catch (Exception e){} }); } } catch (Exception e){} }
protected override void OnCreate(Bundle bundle) { CrushReportEmail = Resources.GetString(Resource.String.CrushReportEmail); base.OnCreate(bundle); SetContentView(Resource.Layout.Main); InitButtonBar(); _adView = FindViewById<AdView>(Resource.Id.adView); InitAdView(); _horizontalScrollView = FindViewById<HorizontalScrollView>(Resource.Id.horizontalScrollView); _formulaTextView = FindViewById<TextView>(Resource.Id.formulaTextView); _renderTimeTextView = FindViewById<TextView>(Resource.Id.renderTimeTextView); _imageView = FindViewById<ImageView>(Resource.Id.imageView); _coresCountTextView = FindViewById<TextView>(Resource.Id.coresCountTextView); TextView sizeTextView = FindViewById<TextView>(Resource.Id.sizeTextView); TextView launcherTextView = FindViewById<TextView>(Resource.Id.launcherTextView); _technicalInfoLayout = FindViewById<LinearLayout>(Resource.Id.technicalInfoLayout); launcherTextView.Text = "launcher: " + IntentShortcuts.GetLauncherPackageName(this); WallpaperManager wallpaperManager = WallpaperManager.GetInstance(this); Point wallpaperSize = wallpaperManager.GetDesiredSize(WindowManager.DefaultDisplay, Resources.Configuration); Size imageSize = new Size(wallpaperSize.X, wallpaperSize.Y); sizeTextView.Text = "image size: " + imageSize.Width + "x" + imageSize.Height; _workflow = new FormulaRenderWorkflow(new FormulaRenderArgumentsGenerationParams(), imageSize, s => new AndroidFormulaBitmap(s)); if (_workflow.FormulaRenderArguments != null) _formulaTextView.Text = _workflow.FormulaRenderArguments.ToString(); _wallpaperFileManager = new AndroidWallpaperFileManager(this); AdjustButtons(); ClearImage(); }
public void AddAds(Grid grid, string adUnitID) { try { const string product = "productRemoveAds"; if (!settings.Contains(product)) { AdView bannerAd = new AdView { Format = AdFormats.Banner, AdUnitID = adUnitID }; AdRequest adRequest = new AdRequest(); adRequest.ForceTesting = true; if (grid != null) { grid.Children.Add(bannerAd); bannerAd.LoadAd(adRequest); } } } catch (Exception ex) { } }
private void AdManager_AdsChanged(bool show) { Dispatcher.BeginInvoke(() => { if (_bannerAd == null) { _bannerAd = new AdView { Format = AdFormats.SmartBanner, AdUnitID = "ca-app-pub-9013851829730737/8303591205" }; //_bannerAd.ReceivedAd += AdBanner_ReceivedAd; //_bannerAd.FailedToReceiveAd += AdBanner_FailedToReceiveAd; _bannerAd.VerticalAlignment = VerticalAlignment.Bottom; } if (show) { DrawingSurfaceBackground.Children.Add(_bannerAd); AdRequest adRequest = new AdRequest(); //adRequest.ForceTesting = true; _bannerAd.LoadAd(adRequest); } else { DrawingSurfaceBackground.Children.Remove(_bannerAd); } }); }
protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); SetContentView (Resource.Layout.activity_banner_xml); adView = FindViewById<AdView> (Resource.Id.adView); adView.AdListener = new ToastAdListener (this); adView.LoadAd (GoogleAdsSampleActivity.GetAdRequest (true)); }
private void LoadAd() { var bannerAd = new AdView { Format = AdFormats.SmartBanner, AdUnitID = GlobalVariables.AdId }; bannerAd.ReceivedAd += OnAdReceived; bannerAd.FailedToReceiveAd += OnFailedToReceiveAd; bannerAd.SetValue(Grid.RowProperty, 4); LayoutRoot.Children.Add(bannerAd); var adRequest = new AdRequest(); bannerAd.LoadAd(adRequest); }
private void LoadAd() { AdView adView = new AdView() { AdUnitID = "ca-app-pub-8694775969775805/9711901013", Format = AdFormats.Banner, VerticalAlignment = System.Windows.VerticalAlignment.Top }; this.ContentPanel.Children.Add(adView); AdRequest req = new AdRequest(); adView.LoadAd(req); adView.FailedToReceiveAd += AdView_FailedToReceiveAd; }
internal static void LoadSmartBanner(Grid gridName) { if (AdsAdmob.showAds) { AdView adView = new AdView { Format = AdFormats.SmartBanner, AdUnitID = AdsAdmob.unitID }; AdRequest adRequest = new AdRequest(); adRequest.ForceTesting = AdsAdmob.fourceTesting; gridName.Children.Add(adView); adView.LoadAd(adRequest); } }
private void Add_GoogleAdMob() { AdView _adview = new AdView() { AdUnitID = "ca-app-pub-8694775969775805/9256987011", Format = AdFormats.Banner, VerticalAlignment = System.Windows.VerticalAlignment.Bottom }; AdRequest adrequest = new AdRequest(); _adview.LoadAd(adrequest); _adview.FailedToReceiveAd += AdView_FailedToReceiveAd; this.ContentPanel.Children.Add(_adview); }
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); } }
protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); // Set our view from the "main" layout resource SetContentView (Resource.Layout.Main); LinearLayout linearLayout = FindViewById<LinearLayout> (Resource.Id.linearLayout); AdView adView = new AdView(this, BANNER_ZONE_ID); adView.LayoutParameters = (new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WrapContent,ViewGroup.LayoutParams.FillParent)); linearLayout.AddView(adView); // Get our button from the layout resource, // and attach an event to it }
// Constructor public MainPage() { InitializeComponent(); // NOTE: Edit "MY_AD_UNIT_ID" with your ad unit id. AdView bannerAd = new AdView { Format = AdFormats.Banner, AdUnitID = "MY_AD_UNIT_ID" }; bannerAd.ReceivedAd += OnAdReceived; bannerAd.FailedToReceiveAd += OnFailedToReceiveAd; LayoutRoot.Children.Add(bannerAd); AdRequest adRequest = new AdRequest(); adRequest.ForceTesting = true; bannerAd.LoadAd(adRequest); }
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)); }
/// <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); } }
/// <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 bannerAd = new AdView { Format = AdFormats.Banner, AdUnitID = adMobElement.AdUnitId, }; AdRequest adRequest = new AdRequest(); bannerAd.LoadAd(adRequest); Children.Add(bannerAd); } }
protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); SetContentView (Resource.Layout.Main); // Create an ad. adView = FindViewById<AdView> (Resource.Id.ad); // Create an ad request. AdRequest adRequest = new AdRequest (); adRequest.SetTesting (true); adRequest.AddTestDevice (AdRequest.TestEmulator); // If you're trying to show ads on device, use this. // The device ID to test will be shown on adb log. // adRequest.AddTestDevice (some_device_id); // Start loading the ad in the background. adView.LoadAd (adRequest); }
protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); SetContentView (Resource.Layout.activity_banner_code_ad_listener); adView = new AdView (this) { AdUnitId = Resources.GetString (Resource.String.ad_unit_id), AdSize = AdSize.Banner, AdListener = new ToastAdListener (this) }; var layout = FindViewById<RelativeLayout> (Resource.Id.mainLayout); var lp = new RelativeLayout.LayoutParams ( ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent); layout.AddView (adView, lp); adView.LoadAd (GoogleAdsSampleActivity.GetAdRequest (true)); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate (savedInstanceState); SetContentView (Resource.Layout.BannerAdLayout); var placementId = Resources.GetString (Resource.String.fb_placement_id); // Instantiate an AdView view adView = new AdView(this, placementId, AdSize.BannerHeight90); // Find the main layout of your activity var layout = FindViewById<LinearLayout> (Resource.Id.container); // Add the ad view to your activity layout layout.AddView (adView); // Request to load an ad adView.LoadAd (); }
public AdMobControl(string appId, string adUnitId) : base(appId, adUnitId, 320, 50, false) { InitializeComponent(); _adView = new AdView { AdUnitID = adUnitId, Format = AdFormats.Banner, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center }; // AdEventArgs does not contain any information at all _adView.ReceivedAd += (sender, args) => OnAdReceived(sender, null); // not called _adView.LeavingApplication += (sender, args) => OnAdEngaged(sender, null); // AdErrorEventArgs only contains ErrorCode _adView.FailedToReceiveAd += (sender, args) => OnAdFailed(sender, new AdvertisementErrorEventArgs(args.ErrorCode.ToString())); LayoutRoot.Children.Add(_adView); }
private void DestroyBasic() { try { MAdView?.Destroy(); MAdapter = null; SwipeRefreshLayout = null; MRecycler = null; EmptyStateLayout = null; Inflated = null; MainScrollEvent = null; BtnAction = null; PageId = null; MAdView = null; } catch (Exception e) { Console.WriteLine(e); } }
private void DestroyBasic() { try { MAdView?.Destroy(); RewardedVideoAd?.OnDestroy(this); MAdapter = null !; SwipeRefreshLayout = null !; MRecycler = null !; EmptyStateLayout = null !; Inflated = null !; MainScrollEvent = null !; MAdView = null !; RewardedVideoAd = null !; } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }
private void InitComponent() { try { MRecycler = (RecyclerView)FindViewById(Resource.Id.recyler); SwipeRefreshLayout = (SwipeRefreshLayout)FindViewById(Resource.Id.swipeRefreshLayout); SwipeRefreshLayout.SetColorSchemeResources(Android.Resource.Color.HoloBlueLight, Android.Resource.Color.HoloGreenLight, Android.Resource.Color.HoloOrangeLight, Android.Resource.Color.HoloRedLight); SwipeRefreshLayout.Refreshing = false; SwipeRefreshLayout.Enabled = false; SwipeRefreshLayout.SetProgressBackgroundColorSchemeColor(AppSettings.SetTabDarkTheme ? Color.ParseColor("#424242") : Color.ParseColor("#f7f7f7")); MAdView = FindViewById <AdView>(Resource.Id.adView); AdsGoogle.InitAdView(MAdView, MRecycler); } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }
private void DestroyBasic() { try { MAdView?.Destroy(); MAdapter = null !; SwipeRefreshLayout = null !; MRecycler = null !; EmptyStateLayout = null !; Inflated = null !; MainScrollEvent = null !; GroupId = null !; ItemJoinRequests = null !; MAdView = null !; } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }
private void InitComponent(View view) { try { MRecycler = (RecyclerView)view.FindViewById(Resource.Id.recyler); EmptyStateLayout = view.FindViewById <ViewStub>(Resource.Id.viewStub); SwipeRefreshLayout = (SwipeRefreshLayout)view.FindViewById(Resource.Id.swipeRefreshLayout); SwipeRefreshLayout.SetColorSchemeResources(Android.Resource.Color.HoloBlueLight, Android.Resource.Color.HoloGreenLight, Android.Resource.Color.HoloOrangeLight, Android.Resource.Color.HoloRedLight); SwipeRefreshLayout.Refreshing = false; SwipeRefreshLayout.Enabled = false; SwipeRefreshLayout.SetProgressBackgroundColorSchemeColor(AppSettings.SetTabDarkTheme ? Color.ParseColor("#424242") : Color.ParseColor("#f7f7f7")); MAdView = view.FindViewById <AdView>(Resource.Id.adView); AdsGoogle.InitAdView(MAdView, MRecycler); } catch (Exception e) { Console.WriteLine(e); } }
protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.View> e) { base.OnElementChanged(e); if (Control == null) { var view = (AdMobBannerView)Element; view.PropertyChanging += View_PropertyChanging; //var adview = new Android.Gms.Ads.NativeExpressAdView(Context); //adview.AdUnitId = Constants.NativeAdId; //adview.AdSize = AdSize.SmartBanner; bannerView = new AdView(Context); if (view.BannerSize == AdMobBannerSizes.LargeBanner) { bannerView.AdSize = AdSize.LargeBanner; } else if (view.BannerSize == AdMobBannerSizes.MediumRectangle) { bannerView.AdSize = AdSize.MediumRectangle; } bannerView.AdUnitId = view.UnitId; base.SetNativeControl(bannerView); if (view.AdMob != null) { view.AdMob.Context = Context; var request = view.AdMob.GetDefaultRequest(); if (!string.IsNullOrWhiteSpace(bannerView.AdUnitId)) { bannerView.LoadAd(request); } } bannerView.SetBackgroundColor(global::Android.Graphics.Color.Transparent); } }
protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.View> e) { base.OnElementChanged(e); if (e.NewElement == null) { return; } if (e.OldElement == null) { var view = (AdMobBannerView)Element; view.PropertyChanged += View_PropertyChanged; var size = AdSizeCons.LargeBanner; if (view.BannerSize == AdMobBannerSizes.MediumRectangle) { size = AdSizeCons.MediumRectangle; } bannerView = new BannerView(size: AdSizeCons.LargeBanner, origin: new CGPoint(0, 0)) { AdUnitId = view.UnitId, RootViewController = ViewController }; bannerView.AdReceived += (sender, args) => { if (!viewOnScreen) { this.AddSubview(bannerView); } viewOnScreen = true; }; bannerView.ReceiveAdFailed += (sender, args) => { }; if (!string.IsNullOrWhiteSpace(bannerView.AdUnitId)) { LoadRequest(); } base.SetNativeControl(bannerView); } }
// Load Banner button public void LoadBanner() { if (adView) { adView.Dispose(); } statusLabel.text = "Loading Banner..."; // Create a banner's ad view with a unique placement ID (generate your own on the Facebook app settings). // Use different ID for each ad placement in your app. adView = new AdView("YOUR_PLACEMENT_ID", AdSize.BANNER_HEIGHT_50); adView.Register(gameObject); currentAdViewPosition = AdPosition.CUSTOM; // Set delegates to get notified on changes or when the user interacts with the ad. adView.AdViewDidLoad = delegate() { currentScreenOrientation = Screen.orientation; adView.Show(100); string isAdValid = adView.IsValid() ? "valid" : "invalid"; statusLabel.text = "Banner loaded and is " + isAdValid + "."; }; adView.AdViewDidFailWithError = delegate(string error) { statusLabel.text = "Banner failed to load with error: " + error; }; adView.AdViewWillLogImpression = delegate() { statusLabel.text = "Banner logged impression."; }; adView.AdViewDidClick = delegate() { statusLabel.text = "Banner clicked."; }; // Initiate a request to load an ad. adView.LoadAd(); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.Main); btnConnect = FindViewById <Button>(Resource.Id.btnConnect); txtIP = FindViewById <TextView>(Resource.Id.txtIP); txtPort = FindViewById <TextView>(Resource.Id.txtPort); adView = FindViewById <AdView>(Resource.Id.ad); AdRequest adRequest = new AdRequest(); #if DEBUG adRequest.SetTesting(true); adRequest.AddTestDevice(AdRequest.TestEmulator); #endif adView.LoadAd(adRequest); btnConnect.Click += btnConnect_Click; string ipFrom = Intent.GetStringExtra("ip"); string portFrom = Intent.GetStringExtra("port"); if (string.IsNullOrEmpty(ipFrom) == false) { txtIP.Text = ipFrom; } if (string.IsNullOrEmpty(portFrom) == false) { txtPort.Text = portFrom; } #if DEBUG txtIP.Text = "192.168.1.84"; #else // txtIP.Text = "192.168.1.84"; #endif }
private void SetRecyclerViewAdapters(View view) { try { MoreRecylerView = (RecyclerView)view.FindViewById(Resource.Id.Recyler); MoreRecylerView.NestedScrollingEnabled = true; MoreSectionAdapter = new MoreSectionAdapter(Activity); switch (AppSettings.MoreTheme) { case MoreTheme.BeautyTheme: { var layoutManager = new GridLayoutManager(Activity, 4); var countListFirstRow = MoreSectionAdapter.SectionList.Where(q => q.StyleRow == 0).ToList().Count; layoutManager.SetSpanSizeLookup(new MySpanSizeLookup2(countListFirstRow, 1, 4)); //20, 1, 4 MoreRecylerView.SetLayoutManager(layoutManager); MoreRecylerView.SetAdapter(MoreSectionAdapter); break; } default: MoreRecylerView.SetLayoutManager(new LinearLayoutManager(Activity)); MoreRecylerView.SetAdapter(MoreSectionAdapter); break; } //MoreRecylerView.HasFixedSize = true; MoreRecylerView.SetItemViewCacheSize(50); MoreRecylerView.GetLayoutManager().ItemPrefetchEnabled = true; MAdView = view.FindViewById <AdView>(Resource.Id.adView); AdsGoogle.InitAdView(MAdView, MoreRecylerView); } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }
protected override void OnCreate(Bundle savedInstanceState) { try { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.lyoutpdf); Android.Support.V7.Widget.Toolbar toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar); SetSupportActionBar(toolbar); ads1 = FindViewById <AdView>(Resource.Id.adView1Lyoutpdf); ads2 = FindViewById <AdView>(Resource.Id.adView2Lyoutpdf); var adRequest1 = new AdRequest.Builder().Build(); ads1.LoadAd(adRequest1); var adRequest2 = new AdRequest.Builder().Build(); ads2.LoadAd(adRequest2); // Back Home SupportActionBar.SetDisplayHomeAsUpEnabled(true); SupportActionBar.SetHomeButtonEnabled(true); toolbar.SetTitleTextColor(Android.Graphics.Color.Rgb(0, 250, 154)); toolbar.SetBackgroundColor(Android.Graphics.Color.Rgb(27, 49, 71)); SupportActionBar.Title = "PDF"; var pdf = FindViewById <PDFView>(Resource.Id.pDFView1); a = Intent.GetStringExtra("a"); Java.IO.File fileStream = new Java.IO.File(a); pdf.FromFile(a).Show(); } catch (Exception ex) { Toast.MakeText(this, ex.Message, ToastLength.Long).Show(); } }
private void InitComponent(View view) { try { MRecycler = (RecyclerView)view.FindViewById(Resource.Id.recyler); EmptyStateLayout = view.FindViewById <ViewStub>(Resource.Id.viewStub); SwipeRefreshLayout = (SwipeRefreshLayout)view.FindViewById(Resource.Id.swipeRefreshLayout); SwipeRefreshLayout.SetColorSchemeResources(Android.Resource.Color.HoloBlueLight, Android.Resource.Color.HoloGreenLight, Android.Resource.Color.HoloOrangeLight, Android.Resource.Color.HoloRedLight); SwipeRefreshLayout.Refreshing = false; SwipeRefreshLayout.Enabled = true; SwipeRefreshLayout.SetProgressBackgroundColorSchemeColor(AppSettings.SetTabDarkTheme ? Color.ParseColor("#424242") : Color.ParseColor("#f7f7f7")); SwipeRefreshLayout.Refresh += SwipeRefreshLayoutOnRefresh; LayoutFriendRequest = (RelativeLayout)view.FindViewById(Resource.Id.layout_friend_Request); FriendRequestImage1 = (ImageView)view.FindViewById(Resource.Id.image_page_1); FriendRequestImage2 = (ImageView)view.FindViewById(Resource.Id.image_page_2); FriendRequestImage3 = (ImageView)view.FindViewById(Resource.Id.image_page_3); TxTFriendRequest = (TextView)view.FindViewById(Resource.Id.tv_Friends_connection); TxtAllFriendRequest = (TextView)view.FindViewById(Resource.Id.tv_Friends); if (AppSettings.ConnectivitySystem == 1) { TxTFriendRequest.Text = Context.GetString(Resource.String.Lbl_FollowRequest); TxtAllFriendRequest.Text = Context.GetString(Resource.String.Lbl_View_All_FollowRequest); } LayoutFriendRequest.Click += LayoutFriendRequestOnClick; LayoutFriendRequest.Visibility = ViewStates.Gone; MAdView = view.FindViewById <AdView>(Resource.Id.adView); AdsGoogle.InitAdView(MAdView, MRecycler); } catch (Exception e) { Console.WriteLine(e); } }
public AdMob_AdPlugin_Native(AdDesc desc, AdCreatedCallbackMethod createdCallback) { eventCallback = desc.EventCallback; testing = desc.Testing; WinRTPlugin.Dispatcher.BeginInvoke(delegate() { bool pass = true; try { adView = new AdView(); setGravity(desc.WP8_AdMob_AdGravity); adView.AdUnitID = desc.WP8_AdMob_UnitID; adView.Format = desc.WP8_AdMob_AdSize == WP8_AdMob_AdSize.Banner ? AdFormats.Banner : AdFormats.SmartBanner; setVisible(desc.Visible); adView.ReceivedAd += adView_ReceivedAd; adView.FailedToReceiveAd += adView_FailedToReceiveAd; WinRTPlugin.AdGrid.Children.Add(adView); AdRequest request = new AdRequest(); //request.ForceTesting = desc.Testing;// Looks like there is a bug in AdMob if this is enabled. adView.LoadAd(request); Debug.Log("Created Ad of AdUnitID: " + adView.AdUnitID); } catch (Exception e) { pass = false; Debug.LogError(e.Message); } if (createdCallback != null) { createdCallback(pass); } }); }
/// <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 AdMobView; if ((adMobElement != null) && (e.OldElement == null)) { var ad = new AdView(Context) { AdSize = AdSize.Banner, AdUnitId = adMobElement.AdUnitId }; var requestbuilder = new AdRequest.Builder(); ad.LoadAd(requestbuilder.Build()); SetNativeControl(ad); } }
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().AddTestDevice(AdRequest.DeviceIdEmulator); if (_TestDevices?.Length > 0) { foreach (string thisTestDevice in _TestDevices) { requestbuilder.AddTestDevice(thisTestDevice); } } adview.LoadAd(requestbuilder.Build()); base.SetNativeControl(adview); } }
private void InitComponent() { try { PasswordEditText = FindViewById <EditText>(Resource.Id.passwordEdit); DeleteCheckBox = FindViewById <CheckBox>(Resource.Id.DeleteCheckBox); DeleteButton = FindViewById <Button>(Resource.Id.DeleteButton); DeleteCheckBox.Text = GetText(Resource.String.Lbl_IWantToDelete1) + " " + UserDetails.Username + " " + GetText(Resource.String.Lbl_IWantToDelete2) + " " + AppSettings.ApplicationName + " " + GetText(Resource.String.Lbl_IWantToDelete3); Methods.SetColorEditText(PasswordEditText, AppSettings.SetTabDarkTheme ? Color.White : Color.Black); MAdView = FindViewById <AdView>(Resource.Id.adView); AdsGoogle.InitAdView(MAdView, null); } catch (Exception e) { Console.WriteLine(e); } }
/// <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 bannerAd = new AdView { Format = AdFormats.Banner, AdUnitID = adMobElement.AdUnitId, }; AdRequest request = new AdRequest(); #if DEBUG request.ForceTesting = true; #endif bannerAd.LoadAd(request); Children.Add(bannerAd); } }
protected override bool DoPreLoadAd() { if (string.IsNullOrEmpty(m_Config.unitID)) { return(false); } if (m_BannerView == null) { m_BannerView = new AdView(m_Config.unitID, ConvertAdSize(m_AdInterface.adSize)); m_BannerView.Register(UIMgr.S.uiRoot.gameObject); m_BannerView.AdViewDidLoad += HandleOnAdLoaded; m_BannerView.AdViewDidFailWithError += HandleOnAdFailedToLoad; m_BannerView.AdViewWillLogImpression += HandleOnAdOpened; //m_BannerView.DisableAutoRefresh(); } return(true); }
private void InitComponent() { try { HybridView = FindViewById <WebView>(Resource.Id.LocalWebView); SwipeRefreshLayout = (SwipeRefreshLayout)FindViewById(Resource.Id.swipeRefreshLayout); SwipeRefreshLayout.SetColorSchemeResources(Android.Resource.Color.HoloBlueLight, Android.Resource.Color.HoloGreenLight, Android.Resource.Color.HoloOrangeLight, Android.Resource.Color.HoloRedLight); SwipeRefreshLayout.Refreshing = true; SwipeRefreshLayout.Enabled = true; SwipeRefreshLayout.SetProgressBackgroundColorSchemeColor(AppSettings.SetTabDarkTheme ? Color.ParseColor("#424242") : Color.ParseColor("#f7f7f7")); MAdView = FindViewById <AdView>(Resource.Id.adView); MAdView.Visibility = ViewStates.Gone; //AdsGoogle.InitAdView(MAdView, null); } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }
private void InitComponent(View view) { try { MRecycler = view.FindViewById <RecyclerView>(Resource.Id.recyler); EmptyStateLayout = view.FindViewById <ViewStub>(Resource.Id.viewStub); SwipeRefreshLayout = view.FindViewById <SwipeRefreshLayout>(Resource.Id.swipeRefreshLayout); SwipeRefreshLayout.SetColorSchemeResources(Android.Resource.Color.HoloBlueLight, Android.Resource.Color.HoloGreenLight, Android.Resource.Color.HoloOrangeLight, Android.Resource.Color.HoloRedLight); SwipeRefreshLayout.Refreshing = true; SwipeRefreshLayout.Enabled = true; SwipeRefreshLayout.SetProgressBackgroundColorSchemeColor(AppSettings.SetTabDarkTheme ? Color.ParseColor("#424242") : Color.ParseColor("#f7f7f7")); SwipeRefreshLayout.Refresh += SwipeRefreshLayoutOnRefresh; LinearLayout adContainer = view.FindViewById <LinearLayout>(Resource.Id.bannerContainer); BannerAd = AdsFacebook.InitAdView(Activity, adContainer); } catch (Exception e) { Console.WriteLine(e); } }
/*<Summary> * Will destroy the current ad if need be * When the ad is created, the index of the ad is saved out * We find the child at the index of the ad and then remove it with extreme predjudice * </Summery>*/ public void HandleDestruction() { if (!_isAdPresent) { return; } #if WINDOWS_PHONE Dispatcher.InvokeOnUIThread(() => { baseGrid.Children.RemoveAt(_adIndex); }); _ad = null; _ad_Google = null; #elif NETFX_CORE Dispatcher.InvokeOnUIThread(() => { backPanel.Children.RemoveAt(_adIndex); }); _ad = null; #endif }
public AdMobControl(string adName, string appId, string adUnitId, int retryLimit) : base(adName, (DataTrackingPortal.AdProvider.AdMob).ToString(), appId, adUnitId, retryLimit, 320, 50, false) { //: base(((int)DataTrackingPortal.AdProvider.AdMob).ToString(), appId, adUnitId, 320, 50, false){ InitializeComponent(); _adView = new AdView { AdUnitID = adUnitId, Format = AdFormats.Banner, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Bottom }; // AdEventArgs does not contain any information at all _adView.ReceivedAd += (sender, args) => OnAdReceived(this, null); // not called _adView.LeavingApplication += (sender, args) => OnAdEngaged(this, null); // AdErrorEventArgs only contains ErrorCode _adView.FailedToReceiveAd += (sender, args) => OnAdFailed(this, args.ErrorCode.ToString()); LayoutRoot.Children.Add(_adView); }
private void DestroyBasic() { try { MAdView?.Destroy(); MAdapter = null; SwipeRefreshLayout = null; MRecycler = null; EmptyStateLayout = null; Inflated = null; Instance = null; CreateButton = null; TxtSuggestedGroups = null; UserId = null; MAdView = null; } catch (Exception e) { Console.WriteLine(e); } }
private void DestroyBasic() { try { MAdView?.Destroy(); MAdapter = null; SwipeRefreshLayout = null; MRecycler = null; EmptyStateLayout = null; Inflated = null; ItemUser = null; InviteFriendsButton = null; PageId = null; MAdView = null; PageDataClass = null; } catch (Exception e) { Console.WriteLine(e); } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); SetContentView(Resource.Layout.activity_main); Toolbar toolbar = FindViewById <Toolbar>(Resource.Id.toolbar); //SetSupportActionBar(toolbar); FloatingActionButton fab = FindViewById <FloatingActionButton>(Resource.Id.fab); fab.Click += FabOnClick; string id = "YOUR_ADMOB_APP_ID"; global::Android.Gms.Ads.MobileAds.Initialize(ApplicationContext, id); AdView adView = FindViewById <AdView>(Resource.Id.adView); AdRequest adRequest = new AdRequest.Builder().Build(); adView.LoadAd(adRequest); }
protected override void OnCreate(Bundle savedInstance) { base.OnCreate(savedInstance); SetContentView(R.Layout.MainActivity); // Create the adView adView = new AdView(this, AdSize.BANNER, MY_AD_UNIT_ID); // Lookup your LinearLayout assuming it's been given // the attribute android:id="@+id/mainLayout" var layout = FindViewById<LinearLayout>(UsingGoogleMobAds.R.Id.mainLayout); // Add the adView to it layout.AddView(adView); // Initiate a generic request to load it with an ad var adRequest = new AdRequest(); adRequest.AddTestDevice("A3DD5CC21FB10074BE918999C41356D8"); // See adb logcat adView.LoadAd(adRequest); }
public override void ViewDidLoad() { base.ViewDidLoad(); if (YourPlacementId == "YOUR_PLACEMENT_ID") { ShowMessage("Please, replace \"YOUR_PLACEMENT_ID\" value with your generated Id"); btnAudience.Enabled = false; btnIntersitial.Enabled = false; return; } try { // Create a banner's ad view with a unique placement ID (generate your own on the Facebook app settings). // Use different ID for each ad placement in your app. adView = new AdView(YourPlacementId, AdSizes.BannerHeight50, this) { Delegate = this }; // When testing on a device, add its hashed ID to force test ads. // The hash ID is printed to console when running on a device. // FBAdSettings.AddTestDevice ("THE HASHED ID AS PRINTED TO CONSOLE"); // Initiate a request to load an ad. adView.LoadAd(); // Reposition the adView to the bottom of the screen var viewSize = View.Bounds.Size; var bottomAlignedY = viewSize.Height - AdSizes.BannerHeight50.Size.Height; adView.Frame = new CGRect(0, bottomAlignedY, viewSize.Width, AdSizes.BannerHeight50.Size.Height); // Add adView to the view hierarchy. View.AddSubview(adView); } catch (Exception ex) { ShowMessage("An error was occurred while the AdView was creating...\nPlease, double check that your PlacementId is correct."); } }
private void DestroyBasic() { try { MAdView?.Destroy(); MAdapter = null !; SwipeRefreshLayout = null !; MRecycler = null !; EmptyStateLayout = null !; Inflated = null !; ItemUser = null !; InviteFriendsButton = null !; PageId = null !; MAdView = null !; PageDataClass = null !; } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }
private void DestroyBasic() { try { MAdView?.Destroy(); MAdapter = null !; SwipeRefreshLayout = null !; MRecycler = null !; EmptyStateLayout = null !; Inflated = null !; MainScrollEvent = null !; BtnFilter = null !; CategoryId = null !; UserId = null !; MAdView = null !; } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.Main); btnConnect = FindViewById<Button>(Resource.Id.btnConnect); txtIP = FindViewById<TextView>(Resource.Id.txtIP); txtPort = FindViewById<TextView>(Resource.Id.txtPort); adView = FindViewById<AdView>(Resource.Id.ad); AdRequest adRequest = new AdRequest(); #if DEBUG adRequest.SetTesting(true); adRequest.AddTestDevice(AdRequest.TestEmulator); #endif adView.LoadAd(adRequest); btnConnect.Click += btnConnect_Click; string ipFrom = Intent.GetStringExtra("ip"); string portFrom = Intent.GetStringExtra("port"); if (string.IsNullOrEmpty(ipFrom) == false) { txtIP.Text = ipFrom; } if (string.IsNullOrEmpty(portFrom) == false) { txtPort.Text = portFrom; } #if DEBUG txtIP.Text = "192.168.1.84"; #else // txtIP.Text = "192.168.1.84"; #endif }
public async Task <ActionResult <AdView> > GetAd(int id) { var ad = await _context.Ads.FindAsync(id); if (ad == null) { return(NotFound()); } var adView = new AdView { Id = ad.Id, Title = ad.Title, Price = ad.Price, Description = ad.Description, PostedDate = ad.PostedDate, ThumbnailUrl = _storageService.GetMediaUrl(ad.Thumbnail), ImageUrl = _storageService.GetMediaUrl(ad.Image) }; return(adView); }
public void LoadBannerAd() { StatusShow.instance.ShowAdStatus("Loading Banner..."); if (bannerAdView) { bannerAdView.Dispose(); } bannerAdView = new AdView(bannerAdId, bannerAdSize); bannerAdView.Register(gameObject); bannerAdView.AdViewDidLoad = delegate() { LoadingBannerAdSuccessful(); }; bannerAdView.AdViewDidFailWithError = delegate(string error) { LoadingBannerAdFaild(); }; bannerAdView.LoadAd(); }
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(Forms.Context); adView.AdSize = adSize; adView.AdUnitId = adUnitId; var adParams = new LinearLayout.LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent); adView.LayoutParameters = adParams; adView.LoadAd(new AdRequest .Builder() .Build()); return(adView); }
/// <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 AdMobView; if ((adMobElement != null) && (e.OldElement == null)) { var bannerAd = new AdView { Format = AdFormats.Banner, AdUnitID = adMobElement.AdUnitId, }; var adRequest = new AdRequest(); bannerAd.LoadAd(adRequest); bannerAd.DismissingOverlay += (sender, args) => { }; bannerAd.FailedToReceiveAd += (sender, args) => { }; bannerAd.ReceivedAd += (sender, args) => { }; bannerAd.ShowingOverlay += (sender, args) => { }; Children.Add(bannerAd); } }
public AdMob_AdPlugin_Native(AdDesc desc, AdCreatedCallbackMethod createdCallback) { eventCallback = desc.EventCallback; testing = desc.Testing; WinRTPlugin.Dispatcher.BeginInvoke(delegate() { bool pass = true; try { adView = new AdView(); setGravity(desc.WP8_AdMob_AdGravity); adView.AdUnitID = desc.WP8_AdMob_UnitID; adView.Format = desc.WP8_AdMob_AdSize == WP8_AdMob_AdSize.Banner ? AdFormats.Banner : AdFormats.SmartBanner; setVisible(desc.Visible); adView.ReceivedAd += adView_ReceivedAd; adView.FailedToReceiveAd += adView_FailedToReceiveAd; WinRTPlugin.AdGrid.Children.Add(adView); AdRequest request = new AdRequest(); //request.ForceTesting = desc.Testing;// Looks like there is a bug in AdMob if this is enabled. adView.LoadAd(request); Debug.Log("Created Ad of AdUnitID: " + adView.AdUnitID); } catch (Exception e) { pass = false; Debug.LogError(e.Message); } if (createdCallback != null) createdCallback(pass); }); }
/// <summary> /// Create a banner view readyfor loaded with an advert and shown /// args JSON format is: /// { /// publisherId: "Publisher ID 1 for banners" /// adSize: "BANNER" or "SMART_BANNER" /// bannerAtTop: "true" or "false" /// overlap: "true" or "false" /// autoShow: "true" or "false" /// } /// /// Note: if autoShow is set to true then additional parameters can be set above: /// isTesting: "true" or "false" (Set to true for live deployment) /// birthday: "2014-09-25" Optional date for advert targeting /// gender: "male" or "female" Optional gender for advert targeting /// location: "true" or "false" Optional geolocation for advert targeting /// keywords: "list of space separated keywords" Limit ad targeting /// </summary> /// <param name="args">JSON format arguments</param> public void createBannerView(string args) { //Debug.WriteLine("AdMob.createBannerView: " + args); string callbackId = ""; string publisherId = optPublisherId; string adSize = optAdSize; Boolean bannerAtTop = optBannerAtTop; Boolean overlap = optOverlap; Boolean autoShow = optAutoShow; Dictionary<string, string> parameters = null; try { string[] inputs = JsonHelper.Deserialize<string[]>(args); if (inputs != null && inputs.Length >= 1) { if (inputs.Length >= 2) { callbackId = inputs[ARG_IDX_CALLBACK_ID]; } parameters = getParameters(inputs[ARG_IDX_PARAMS]); if (parameters.ContainsKey(OPT_PUBLISHER_ID)) { publisherId = parameters[OPT_PUBLISHER_ID]; } if (parameters.ContainsKey(OPT_AD_SIZE)) { adSize = parameters[OPT_AD_SIZE]; } if (parameters.ContainsKey(OPT_BANNER_AT_TOP)) { bannerAtTop = Convert.ToBoolean(parameters[OPT_BANNER_AT_TOP]); } if (parameters.ContainsKey(OPT_OVERLAP)) { overlap = Convert.ToBoolean(parameters[OPT_OVERLAP]); } if (parameters.ContainsKey(OPT_AUTO_SHOW)) { autoShow = Convert.ToBoolean(parameters[OPT_AUTO_SHOW]); } } } catch { //Debug.WriteLine("AdMob.createBannerView: Error - invalid JSON format - " + args); DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION, "Invalid JSON format - " + args), callbackId); return; } if (bannerAd == null) { // Asynchronous UI threading call Deployment.Current.Dispatcher.BeginInvoke(() => { PhoneApplicationFrame frame = Application.Current.RootVisual as PhoneApplicationFrame; if (frame != null) { PhoneApplicationPage page = frame.Content as PhoneApplicationPage; if (page != null) { Grid grid = page.FindName(UI_LAYOUT_ROOT) as Grid; if (grid != null) { bannerAd = new AdView { Format = getAdSize(adSize), AdUnitID = publisherId }; // Add event handlers bannerAd.FailedToReceiveAd += onFailedToReceiveAd; bannerAd.LeavingApplication += onLeavingApplicationAd; bannerAd.ReceivedAd += onReceivedAd; bannerAd.ShowingOverlay += onShowingOverlayAd; bannerAd.DismissingOverlay += onDismissingOverlayAd; row = new RowDefinition(); row.Height = GridLength.Auto; CordovaView view = page.FindName(UI_CORDOVA_VIEW) as CordovaView; if (view != null && bannerAtTop) { grid.RowDefinitions.Insert(0,row); grid.Children.Add(bannerAd); Grid.SetRow(bannerAd, 0); Grid.SetRow(view, 1); } else { grid.RowDefinitions.Add(row); grid.Children.Add(bannerAd); Grid.SetRow(bannerAd, 1); } initialViewHeight = view.ActualHeight; initialViewWidth = view.ActualWidth; if (!overlap) { setCordovaViewHeight(frame, view); frame.OrientationChanged += onOrientationChanged; } bannerAd.Visibility = Visibility.Visible; if (autoShow) { // Chain request and show calls together if(doRequestAd(parameters) == null) { doShowAd(true); } } } } } }); } DispatchCommandResult(new PluginResult(PluginResult.Status.OK), callbackId); }
/// <summary> /// Destroy advert banner removing it from the display /// </summary> /// <param name="args">Not used</param> public void destroyBannerView(string args) { //Debug.WriteLine("AdMob.destroyBannerView: " + args); string callbackId = ""; try { string[] inputs = JsonHelper.Deserialize<string[]>(args); if (inputs != null && inputs.Length >= 1) { if (inputs.Length >= 2) { callbackId = inputs[ARG_IDX_CALLBACK_ID]; } } } catch { // Do nothing } // Asynchronous UI threading call Deployment.Current.Dispatcher.BeginInvoke(() => { if (row != null) { PhoneApplicationFrame frame = Application.Current.RootVisual as PhoneApplicationFrame; if (frame != null) { frame.OrientationChanged -= onOrientationChanged; PhoneApplicationPage page = frame.Content as PhoneApplicationPage; if (page != null) { Grid grid = page.FindName(UI_LAYOUT_ROOT) as Grid; if (grid != null) { grid.Children.Remove(bannerAd); grid.RowDefinitions.Remove(row); // Remove event handlers bannerAd.FailedToReceiveAd -= onFailedToReceiveAd; bannerAd.LeavingApplication -= onLeavingApplicationAd; bannerAd.ReceivedAd -= onReceivedAd; bannerAd.ShowingOverlay -= onShowingOverlayAd; bannerAd.DismissingOverlay -= onDismissingOverlayAd; bannerAd = null; row = null; } } } } }); DispatchCommandResult(new PluginResult(PluginResult.Status.OK), callbackId); }