com.facebook.ads.AdSize Java Examples
The following examples show how to use
com.facebook.ads.AdSize.
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: BannerFragment.java From kognitivo with Apache License 2.0 | 6 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Initialize status label statusLabel = getString(R.string.loading_status); // 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. boolean isTablet = getResources().getBoolean(R.bool.is_tablet); adViewBanner = new AdView(this.getActivity(), "YOUR_PLACEMENT_ID", isTablet ? AdSize.BANNER_HEIGHT_90 : AdSize.BANNER_HEIGHT_50); // Set a listener to get notified on changes or when the user interact with the ad. adViewBanner.setAdListener(this); // Initiate a request to load an ad. adViewBanner.loadAd(); }
Example #2
Source File: BannerViewManager.java From react-native-fbads with MIT License | 6 votes |
@ReactProp(name = "size") public void setSize(BannerView view, int size) { AdSize adSize = null; switch (size) { case 90: adSize = AdSize.BANNER_HEIGHT_90; break; case 250: adSize = AdSize.RECTANGLE_HEIGHT_250; break; case 50: default: adSize = AdSize.BANNER_HEIGHT_50; break; } view.setSize(adSize); }
Example #3
Source File: FacebookBanner.java From mobile-sdk-android with Apache License 2.0 | 6 votes |
@Override public View requestAd(MediatedBannerAdViewController mBC, Activity activity, String parameter, String uid, int width, int height, TargetingParameters tp) { FacebookListener fbListener = new FacebookListener(mBC, this.getClass().getSimpleName()); AdSize adSize; if (width == 320 && height == 50) { adSize = AdSize.BANNER_320_50; } else if (height == 50) { adSize = AdSize.BANNER_HEIGHT_50; } else if (height == 90) { adSize = AdSize.BANNER_HEIGHT_90; } else if (height == 250) { adSize = AdSize.RECTANGLE_HEIGHT_250; } else { Clog.e(Clog.mediationLogTag, "Facebook - Attempted to instantiate with size other than the allowed size of 320x50, -1x50, -1x90, -1x250"); mBC.onAdFailed(ResultCode.UNABLE_TO_FILL); return null; } adView = new AdView(activity, uid, adSize); adView.setAdListener(fbListener); adView.loadAd(); return adView; }
Example #4
Source File: RectangleFragment.java From kognitivo with Apache License 2.0 | 5 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Initialize status label statusLabel = getString(R.string.loading_status); adViewRectangle = new AdView(this.getActivity(), "YOUR_PLACEMENT_ID", AdSize.RECTANGLE_HEIGHT_250); // Set a listener to get notified on changes or when the user interact with the ad. adViewRectangle.setAdListener(this); // Initiate a request to load an ad. adViewRectangle.loadAd(); }
Example #5
Source File: BannerView.java From react-native-fbads with MIT License | 4 votes |
public void setSize(AdSize size) { mSize = size; createAdViewIfCan(); }