Java Code Examples for com.google.android.gms.ads.AdSize#SMART_BANNER
The following examples show how to use
com.google.android.gms.ads.AdSize#SMART_BANNER .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RNPublisherBannerViewManager.java From react-native-admob with BSD 2-Clause "Simplified" License | 6 votes |
private void sendOnSizeChangeEvent() { int width; int height; ReactContext reactContext = (ReactContext) getContext(); WritableMap event = Arguments.createMap(); AdSize adSize = this.adView.getAdSize(); if (adSize == AdSize.SMART_BANNER) { width = (int) PixelUtil.toDIPFromPixel(adSize.getWidthInPixels(reactContext)); height = (int) PixelUtil.toDIPFromPixel(adSize.getHeightInPixels(reactContext)); } else { width = adSize.getWidth(); height = adSize.getHeight(); } event.putDouble("width", width); event.putDouble("height", height); sendEvent(RNPublisherBannerViewManager.EVENT_SIZE_CHANGE, event); }
Example 2
Source File: RNPublisherBannerViewManager.java From react-native-admob with BSD 2-Clause "Simplified" License | 6 votes |
private AdSize getAdSizeFromString(String adSize) { switch (adSize) { case "banner": return AdSize.BANNER; case "largeBanner": return AdSize.LARGE_BANNER; case "mediumRectangle": return AdSize.MEDIUM_RECTANGLE; case "fullBanner": return AdSize.FULL_BANNER; case "leaderBoard": return AdSize.LEADERBOARD; case "smartBannerPortrait": return AdSize.SMART_BANNER; case "smartBannerLandscape": return AdSize.SMART_BANNER; case "smartBanner": return AdSize.SMART_BANNER; default: return AdSize.BANNER; } }
Example 3
Source File: RNAdMobBannerViewManager.java From react-native-admob with BSD 2-Clause "Simplified" License | 6 votes |
private void sendOnSizeChangeEvent() { int width; int height; ReactContext reactContext = (ReactContext) getContext(); WritableMap event = Arguments.createMap(); AdSize adSize = this.adView.getAdSize(); if (this.adSize == AdSize.SMART_BANNER) { width = (int) PixelUtil.toDIPFromPixel(adSize.getWidthInPixels(reactContext)); height = (int) PixelUtil.toDIPFromPixel(adSize.getHeightInPixels(reactContext)); } else { width = adSize.getWidth(); height = adSize.getHeight(); } event.putDouble("width", width); event.putDouble("height", height); sendEvent(RNAdMobBannerViewManager.EVENT_SIZE_CHANGE, event); }
Example 4
Source File: RNAdMobBannerViewManager.java From react-native-admob with BSD 2-Clause "Simplified" License | 6 votes |
private AdSize getAdSizeFromString(String adSize) { switch (adSize) { case "banner": return AdSize.BANNER; case "largeBanner": return AdSize.LARGE_BANNER; case "mediumRectangle": return AdSize.MEDIUM_RECTANGLE; case "fullBanner": return AdSize.FULL_BANNER; case "leaderBoard": return AdSize.LEADERBOARD; case "smartBannerPortrait": return AdSize.SMART_BANNER; case "smartBannerLandscape": return AdSize.SMART_BANNER; case "smartBanner": return AdSize.SMART_BANNER; default: return AdSize.BANNER; } }
Example 5
Source File: AdMobPlugin.java From cordova-admob-pro with MIT License | 6 votes |
/** * Gets an AdSize object from the string size passed in from JavaScript. * Returns null if an improper string is provided. * * @param size The string size representing an ad format constant. * @return An AdSize object used to create a banner. */ public static AdSize adSizeFromString(String size) { if ("BANNER".equals(size)) { return AdSize.BANNER; } else if ("SMART_BANNER".equals(size)) { return AdSize.SMART_BANNER; } else if ("MEDIUM_RECTANGLE".equals(size)) { return AdSize.MEDIUM_RECTANGLE; } else if ("FULL_BANNER".equals(size)) { return AdSize.FULL_BANNER; } else if ("LEADERBOARD".equals(size)) { return AdSize.LEADERBOARD; } else if ("SKYSCRAPER".equals(size)) { return AdSize.WIDE_SKYSCRAPER; } else if ("LARGE_BANNER".equals(size)) { return AdSize.LARGE_BANNER; } else { return null; } }
Example 6
Source File: AdMob.java From unity_admob_android with MIT License | 6 votes |
/** * Parses the ad size string obtained from Unity. * * @param adSize * * @return the parsed {@link AdSize}. */ private static AdSize parseAdSize(final String adSize) { if ("BANNER".equals(adSize)) { return AdSize.BANNER; } else if ("MEDIUM_RECTANGLE".equals(adSize)) { return AdSize.MEDIUM_RECTANGLE; } else if ("FULL_BANNER".equals(adSize)) { return AdSize.FULL_BANNER; } else if ("LEADERBOARD".equals(adSize)) { return AdSize.LEADERBOARD; } else if ("SMART_BANNER".equals(adSize)) { return AdSize.SMART_BANNER; } return null; }
Example 7
Source File: GooglePlayDFPBanner.java From mobile-sdk-android with Apache License 2.0 | 6 votes |
/** * Interface called by the AN SDK to request an ad from the mediating SDK. * * @param mBC the object which will be called with events from the 3rd party SDK * @param activity the activity from which this is launched * @param parameter String parameter received from the server for instantiation of this object * @param adUnitID The 3rd party placement, in DFP this is the adUnitID * @param width Width of the ad * @param height Height of the ad * @param targetingParameters targetingParameters */ @Override public View requestAd(MediatedBannerAdViewController mBC, Activity activity, String parameter, String adUnitID, int width, int height, TargetingParameters targetingParameters) { adListener = new GooglePlayAdListener(mBC, super.getClass().getSimpleName()); adListener.printToClog(String.format(" - requesting an ad: [%s, %s, %dx%d]", parameter, adUnitID, width, height)); DFBBannerSSParameters ssparm = new DFBBannerSSParameters(parameter); AdSize adSize = ssparm.isSmartBanner ? AdSize.SMART_BANNER : new AdSize(width, height); adView = new PublisherAdView(activity); adView.setAdUnitId(adUnitID); adView.setAdSizes(adSize); adView.setAdListener(adListener); adView.setAppEventListener(adListener); adView.loadAd(buildRequest(ssparm, targetingParameters)); return adView; }
Example 8
Source File: Action.java From admob-plus with MIT License | 5 votes |
public AdSize getAdSize() { final String name = "size"; if (!this.opts.has(name)) { return AdSize.SMART_BANNER; } AdSize adSize = AdSizeType.getAdSize(this.opts.opt(name)); if (adSize != null) { return adSize; } JSONObject adSizeObj = this.opts.optJSONObject(name); if (adSizeObj == null) { return AdSize.SMART_BANNER; } return new AdSize(adSizeObj.optInt("width"), adSizeObj.optInt("height")); }
Example 9
Source File: AdMobConfig.java From cordova-plugin-admob-free with MIT License | 5 votes |
/** * Gets an AdSize object from the string size passed in from JavaScript. * Returns null if an improper string is provided. * * @param size The string size representing an ad format constant. * @return An AdSize object used to create a banner. */ private static AdSize adSizeFromString(String size) { if ("BANNER".equals(size)) { return AdSize.BANNER; } else if ("FULL_BANNER".equals(size)) { return AdSize.FULL_BANNER; } else if ("LARGE_BANNER".equals(size)) { return AdSize.LARGE_BANNER; } else if ("LEADERBOARD".equals(size)) { return AdSize.LEADERBOARD; } else if ("MEDIUM_RECTANGLE".equals(size)) { return AdSize.MEDIUM_RECTANGLE; } else if ("WIDE_SKYSCRAPER".equals(size)) { return AdSize.WIDE_SKYSCRAPER; } else if ("SMART_BANNER".equals(size)) { return AdSize.SMART_BANNER; } else if ("FLUID".equals(size)) { return AdSize.FLUID; } else if ("SEARCH".equals(size)) { return AdSize.SEARCH; } else if ("IAB_BANNER".equals(size)) { return AdSize.FULL_BANNER; } else if ("IAB_MRECT".equals(size)) { return AdSize.MEDIUM_RECTANGLE; } else if ("IAB_LEADERBOARD".equals(size)) { return AdSize.LEADERBOARD; } return null; }
Example 10
Source File: AdMobManager.java From ANEAdMob with Apache License 2.0 | 5 votes |
public void show(String adID, int size, /*int autoHW,*/ int halign, int valign, String testDevice) { hide(); switch(size) { case 1: _adSize = AdSize.BANNER; break; //set by default, but leave it here for reference case 2: _adSize = AdSize.MEDIUM_RECTANGLE; break; case 3: _adSize = AdSize.FULL_BANNER; break; case 4: _adSize = AdSize.LEADERBOARD; break; case 5: _adSize = AdSize.SMART_BANNER; break; case 6: _adSize = AdSize.WIDE_SKYSCRAPER; break; } _adView = new AdView(_act); _adView.setAdUnitId(adID); _adView.setAdSize(_adSize); AdRequest adRequest = null; if(testDevice == null) //no test device adRequest = new AdRequest.Builder().build(); else adRequest = new AdRequest.Builder().addTestDevice(testDevice).build(); //eto pizdec _adView.setAdListener(new AdMobListener(_ctx, "BANNER")); _params = new RelativeLayout.LayoutParams(-2, -2); _params.addRule(halign, -1); _params.addRule(valign, -1); _parentView.addView(_adView, _params); _adView.loadAd(adRequest); }
Example 11
Source File: AndroidAdMobBanner.java From QtAndroidTools with MIT License | 4 votes |
public void setType(final int type) { if(mBannerView == null) { return; } SyncRunOnUiThread UiThread = new SyncRunOnUiThread(mActivityInstance, new SyncRunOnUiThread.SyncRunOnUiThreadListener() { public void runOnUIThread() { AdSize BannerSize = AdSize.BANNER; switch(type) { case TYPE_BANNER: BannerSize = AdSize.BANNER; break; case TYPE_FULL_BANNER: BannerSize = AdSize.FULL_BANNER; break; case TYPE_LARGE_BANNER: BannerSize = AdSize.LARGE_BANNER; break; case TYPE_MEDIUM_RECTANGLE: BannerSize = AdSize.MEDIUM_RECTANGLE; break; case TYPE_SMART_BANNER: BannerSize = AdSize.SMART_BANNER; break; case TYPE_WIDE_SKYSCRAPER: BannerSize = AdSize.WIDE_SKYSCRAPER; break; } mBannerView.setAdSize(BannerSize); mBannerPixelsSize.width = BannerSize.getWidthInPixels(mActivityInstance); mBannerPixelsSize.height = BannerSize.getHeightInPixels(mActivityInstance); } }); UiThread.exec(); }
Example 12
Source File: TestAdvancedAdmobActivity.java From UltimateRecyclerView with Apache License 2.0 | 4 votes |
private RelativeLayout createadmob() { AdSize adSize = AdSize.SMART_BANNER; DisplayMetrics dm = getResources().getDisplayMetrics(); double density = dm.density * 160; double x = Math.pow(dm.widthPixels / density, 2); double y = Math.pow(dm.heightPixels / density, 2); double screenInches = Math.sqrt(x + y); if (screenInches > 8) { // > 728 X 90 adSize = AdSize.LEADERBOARD; } else if (screenInches > 6) { // > 468 X 60 adSize = AdSize.MEDIUM_RECTANGLE; } else { // > 320 X 50 adSize = AdSize.BANNER; } adSize = AdSize.MEDIUM_RECTANGLE; final AdView mAdView = new AdView(this); mAdView.setAdSize(adSize); mAdView.setAdUnitId("ca-app-pub-3940256099942544/6300978111"); // Create an ad request. AdRequest.Builder adRequestBuilder = new AdRequest.Builder(); if (admob_test_mode) // Optionally populate the ad request builder. adRequestBuilder.addTestDevice(AdRequest.DEVICE_ID_EMULATOR); // Start loading the ad. mAdView.loadAd(adRequestBuilder.build()); DisplayMetrics displaymetrics = new DisplayMetrics(); final RelativeLayout layout = AdGoogleDisplaySupport.initialSupport(this, displaymetrics); final double ratio = AdGoogleDisplaySupport.ratioMatching(displaymetrics); final int ad_height = AdGoogleDisplaySupport.defaultHeight(displaymetrics); AdGoogleDisplaySupport.panelAdjust(mAdView, (int) (ad_height * ratio)); // get display info /* G.display_w = displayMetrics.widthPixels; G.display_h = displayMetrics.heightPixels; G.scale = Math.max(G.display_w/1280.0f, G.display_h/800.0f);*/ mAdView.setAdListener(new AdListener() { @Override public void onAdLoaded() { super.onAdLoaded(); int h = mAdView.getLayoutParams().height; AdGoogleDisplaySupport.scale(mAdView, ratio); AdGoogleDisplaySupport.panelAdjust(mAdView, (int) (h * ratio)); // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) } }); layout.addView(mAdView); return layout; }