/** * Create {@link PublisherAdView} and add to container * * @param context - android context * @param container - parent view for add ad view * @return true if ads has been added */ public static boolean addBannerAds(Context context, @Nullable ViewGroup container) { if (isPremiumUser(context)) { if (container != null) { container.setVisibility(View.GONE); } return false; } else { if (container == null) return false; container.setVisibility(View.VISIBLE); PublisherAdView publisherAdView = new PublisherAdView(context); publisherAdView.setAdSizes(AdSize.SMART_BANNER, AdSize.FLUID); publisherAdView.setAdUnitId(AdConstants.AdUnitId.AD_UNIT_ID_NATIVE_MAIN_320_50); PublisherAdRequest.Builder builder = new PublisherAdRequest.Builder(); if (BuildConfig.DEBUG) builder.addTestDevice(TEST_DEVICE_ID); publisherAdView.loadAd(builder.build()); container.removeAllViews(); container.addView(publisherAdView); } return false; }
@Nullable public static PublisherAdView addBannerAds(Context context, @Nullable ViewGroup container, AdSize... adSizes) { if (isPremiumUser(context)) { if (container != null) { container.setVisibility(View.GONE); } return null; } else { if (container == null) return null; container.setVisibility(View.VISIBLE); PublisherAdView publisherAdView = new PublisherAdView(context); publisherAdView.setAdSizes(adSizes); publisherAdView.setAdUnitId(AdConstants.AdUnitId.AD_UNIT_ID_NATIVE_MAIN_320_50); PublisherAdRequest.Builder builder = new PublisherAdRequest.Builder(); if (BuildConfig.DEBUG) builder.addTestDevice(TEST_DEVICE_ID); publisherAdView.loadAd(builder.build()); container.removeAllViews(); container.addView(publisherAdView); return publisherAdView; } }
private void setupBannerWithWait(final int waitTime) { FrameLayout adFrame = (FrameLayout) root.findViewById(R.id.adFrame2); adFrame.removeAllViews(); adView2 = new PublisherAdView(getActivity()); adView2.setAdUnitId(Constants.DFP_BANNER_ADUNIT_ID_300x250); adView2.setAdSizes(new AdSize(300, 250)); adView2.setAdListener(adListener); adFrame.addView(adView2); //region PriceCheckForDFP API usage PublisherAdRequest.Builder builder = new PublisherAdRequest.Builder(); PublisherAdRequest request = builder.build(); Prebid.attachBidsWhenReady(request, Constants.BANNER_300x250, this, waitTime, this.getActivity()); //endregion }
private void setUpAndLoadNativeExpressAds() { mCoordinatorLayout.post(new Runnable() { @Override public void run() { mNativeExpressAdView = new NativeExpressAdView(getContext()); float scale = getActivity().getResources().getDisplayMetrics().density; int adWidth = mCoordinatorLayout.getWidth(); AdSize adSize = new AdSize((int) (adWidth / scale), NATIVE_EXPRESS_AD_HEIGHT); mNativeExpressAdView.setAdSize(adSize); mNativeExpressAdView.setAdUnitId(getString(R.string.test_ad_unit_id)); mAdViewContainer.addView(mNativeExpressAdView); // Load the first Native Express ad in the items list. AdRequest request = new AdRequest.Builder() .addTestDevice("872EB083722CD10CAB1DB046CEE82A2D") .build(); mNativeExpressAdView.loadAd(request); } }); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final ViewGroup adContainer = findViewById(R.id.adContainer); adsManager = ((MainApplication) getApplicationContext()).getAdsManager(); adsManager.insertAdView(this, adContainer, R.string.admob_footer, AdSize.BANNER); adsManager.loadAndShowInterstitial(R.string.admob_interstitial_install) .subscribe(new Consumer<Boolean>() { @Override public void accept(Boolean aBoolean) throws Exception { } }, new Consumer<Throwable>() { @Override public void accept(Throwable throwable) throws Exception { } }); }
private AdView createAdView() { mAdView = new AdView(this); mAdView.setAdSize(AdSize.LARGE_BANNER); // setup "testing" banner type boolean isStoreBuild = BuildConfig.FLAVOR.equals("playstore") && BuildConfig.BUILD_TYPE.equals("release"); String adUnitId = isStoreBuild ? AD_UNIT_ID : "ca-app-pub-3940256099942544/6300978111"; mAdView.setAdUnitId(adUnitId); mAdView.setId(View.generateViewId()); // this is an arbitrary id, allows for relative positioning in createGameView() RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); params.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); mAdView.setLayoutParams(params); mAdView.setBackgroundColor(Color.BLACK); return mAdView; }
public AdViewHolder(View v ) { super(v); AdRequest request = new AdRequest.Builder() .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .build(); NativeExpressAdView adView = new NativeExpressAdView(v.getContext()); adView.setAdSize(new AdSize(AdSize.FULL_WIDTH, 80)); // Load ad type based on theme - dark or light if (PreferenceManager.getDefaultSharedPreferences(v.getContext()) .getBoolean(PREF_DARK_THEME, false)) { adView.setAdUnitId(DARK_AD_ID); } else { adView.setAdUnitId(LIGHT_AD_ID); } ((LinearLayout) v).addView(adView, 1); adView.loadAd(request); }
@Override protected void request(Context context, Map<String, String> networkData) { if (context == null || networkData == null) { invokeLoadFail(PNException.ADAPTER_ILLEGAL_ARGUMENTS); } else { String unitId = networkData.get(AdMob.KEY_UNIT_ID); if (TextUtils.isEmpty(unitId)) { invokeLoadFail(PNException.ADAPTER_MISSING_DATA); } else { mIsImpressionConfirmed = false; mIsReady = false; mAdView = null; mNativeAd = new NativeExpressAdView(mContext); mNativeAd.setAdSize(new AdSize(WIDTH,HEIGHT)); mNativeAd.setAdUnitId(unitId); mNativeAd.setAdListener(mAdListener); mNativeAd.loadAd(AdMob.getAdRequest(context)); } } }
@Override protected void request(Context context, Map<String, String> networkData) { if (context == null || networkData == null) { invokeLoadFail(PNException.ADAPTER_ILLEGAL_ARGUMENTS); } else { String unitId = networkData.get(AdMob.KEY_UNIT_ID); if (TextUtils.isEmpty(unitId)) { invokeLoadFail(PNException.ADAPTER_MISSING_DATA); } else { mIsReady = false; mAdView = null; mIsImpressionConfirmed = false; mNativeAd = new NativeExpressAdView(mContext); mNativeAd.setAdSize(AdSize.MEDIUM_RECTANGLE); mNativeAd.setAdUnitId(unitId); mNativeAd.setAdListener(mAdListener); mNativeAd.loadAd(AdMob.getAdRequest(context)); } } }
private void initAdvertise() { AdView mAdView = new AdView(this); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); mAdView.setAdUnitId("ca-app-pub-3406938862137540/3927782716"); mAdView.setBackgroundColor(Color.BLACK); AdRequest adRequest = new AdRequest.Builder().build(); double dppxl = (1 * (Resources.getSystem().getDisplayMetrics().densityDpi / 160f)); int v = this.getResources().getDisplayMetrics().heightPixels; RelativeLayout layout = (RelativeLayout) findViewById(R.id.act_main_baseLayout); layout.addView(mAdView, params); if(v/dppxl > 720) mAdView.setAdSize(AdSize.BANNER); else mAdView.setAdSize(AdSize.SMART_BANNER); mAdView.loadAd(adRequest); }
private void adSetup() { nativeAdHolder.post(new Runnable() { @Override public void run() { int maxHeightPixels = nativeAdHolder.getResources().getDimensionPixelSize(R.dimen.admob_ad_height); // Set the ad target size int maxWidthInt = nativeAdHolder.getWidth(); maxWidthInt = (int) (maxWidthInt * 1f / itemView.getResources().getDisplayMetrics().density); int maxHeightInt = (int) (maxHeightPixels * 1f / itemView.getResources().getDisplayMetrics().density); nativeExpressAdView.setAdSize(new AdSize(maxWidthInt, maxHeightInt)); nativeExpressAdView.setAdUnitId(itemView.getContext().getString(adMobIdResource)); // Setup animation finalHeight = maxHeightPixels; } }); }
public final AdSize getAdSize() { try { if (this.zzvb != null) { AdSizeParcel localAdSizeParcel = this.zzvb.zzbb(); if (localAdSizeParcel != null) { AdSize localAdSize = new AdSize(localAdSizeParcel.width, localAdSizeParcel.height, localAdSizeParcel.zzuA); return localAdSize; } } } catch (RemoteException localRemoteException) { com.google.android.gms.ads.internal.util.client.zzb.w("Failed to get the current AdSize.", localRemoteException); if (this.zzuH != null) { return this.zzuH[0]; } } return null; }
public final void zza(AdSize... paramVarArgs) { this.zzuH = paramVarArgs; try { if (this.zzvb != null) { Context localContext = this.zzvd.getContext(); AdSize[] arrayOfAdSize = this.zzuH; boolean bool = this.zzvi; new AdSizeParcel(localContext, arrayOfAdSize).zzuF = bool; } this.zzvd.requestLayout(); return; } catch (RemoteException localRemoteException) { for (;;) { com.google.android.gms.ads.internal.util.client.zzb.w("Failed to set the ad size.", localRemoteException); } } }
private com.facebook.ads.AdSize getAdSize(Context context, AdSize adSize) { if (adSize.getWidth() == com.facebook.ads.AdSize.BANNER_320_50.getWidth() && adSize.getHeight() == com.facebook.ads.AdSize.BANNER_320_50.getHeight()) { return com.facebook.ads.AdSize.BANNER_320_50; } // adSize.getHeight will return -2 for smart banner. So we need to use // adSize.getHeightInPixels here. int heightInDip = pixelToDip(adSize.getHeightInPixels(context)); if (heightInDip == com.facebook.ads.AdSize.BANNER_HEIGHT_50.getHeight()) { return com.facebook.ads.AdSize.BANNER_HEIGHT_50; } if (heightInDip == com.facebook.ads.AdSize.BANNER_HEIGHT_90.getHeight()) { return com.facebook.ads.AdSize.BANNER_HEIGHT_90; } if (heightInDip == com.facebook.ads.AdSize.RECTANGLE_HEIGHT_250.getHeight()) { return com.facebook.ads.AdSize.RECTANGLE_HEIGHT_250; } return null; }
private void addAds() { // add AdMob AdView adView = new AdView(this); adView.setAdUnitId(AD_UNIT_ID); adView.setAdSize(AdSize.SMART_BANNER); LinearLayout.LayoutParams adLayoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); adView.setLayoutParams(adLayoutParams); // 広告表示位置は画面下部 LinearLayout layout = new LinearLayout(this); layout.addView(adView); layout.setGravity(Gravity.BOTTOM); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT); addContentView(layout, layoutParams); // load ad AdRequest adRequest = new AdRequest.Builder().build(); adView.loadAd(adRequest); }
private void ADView() { LinearLayout adBannerLayout = (LinearLayout) findViewById(R.id.footerLayout); adView = new AdView(this); adView.setAdUnitId(Constant.ADMob_BuddhaVoice); adView.setAdSize(AdSize.SMART_BANNER); adBannerLayout.addView(adView); AdRequest adRequest; if (BuddhaVoice.APPDEBUG) { //Test Mode adRequest = new AdRequest.Builder() .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .addTestDevice(Constant.ADMob_TestDeviceID) .build(); } else { adRequest = new AdRequest.Builder().build(); } adView.loadAd(adRequest); }
private void ADView() { LinearLayout adBannerLayout = (LinearLayout) findViewById(R.id.footerLayout); adView = new AdView(this); adView.setAdUnitId(Constant.ADMob_BuddhaVoiceMain); adView.setAdSize(AdSize.SMART_BANNER); adBannerLayout.addView(adView); AdRequest adRequest; if (BuddhaVoice.APPDEBUG) { //Test Mode adRequest = new AdRequest.Builder() .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .addTestDevice(Constant.ADMob_TestDeviceID) .build(); } else { adRequest = new AdRequest.Builder().build(); } adView.loadAd(adRequest); }
private void showGoogleAdMobAds(Activity activity) { try { AdView adView = new AdView(activity); adView.setAdUnitId("ca-app-pub-5619114666968507/6860732934"); adView.setAdSize(AdSize.BANNER); LinearLayout layout = (LinearLayout) activity.findViewById(R.id.adsLayout); // Add the adView to it layout.addView(adView); // Initiate a generic request. AdRequest adRequest = new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .addTestDevice(TESTDEVICE_SGS5) .addTestDevice(TESTDEVICE_SGS3MINI) .addTestDevice(TESTDEVICE_DUOS_Y).build(); // Load the adView with the ad request. adView.loadAd(adRequest); } catch (Exception e) { Log.e(TAG, "Error while getting ads", e); } }
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); }
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; } }
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); }
public ag(ViewGroup paramViewGroup, AttributeSet paramAttributeSet, boolean paramBoolean) { this.eY = paramViewGroup; Context localContext = paramViewGroup.getContext(); try { aa localaa = new aa(localContext, paramAttributeSet); this.eJ = localaa.c(paramBoolean); this.eK = localaa.getAdUnitId(); } catch (IllegalArgumentException localIllegalArgumentException) { cs.a(paramViewGroup, new x(localContext, AdSize.BANNER), localIllegalArgumentException.getMessage(), localIllegalArgumentException.getMessage()); return; } if (paramViewGroup.isInEditMode()) { cs.a(paramViewGroup, new x(localContext, this.eJ[0]), "Ads by Google"); return; } }
public final AdSize getAdSize() { try { if (this.eX != null) { AdSize localAdSize = this.eX.y().P(); return localAdSize; } } catch (RemoteException localRemoteException) { ct.b("Failed to get the current AdSize.", localRemoteException); } if (this.eJ != null) return this.eJ[0]; return null; }
private void loadAd(View view) { //Init ad adView = new AdView(application); adView.setAdUnitId(ApiUtils.AD_UNIT_ID_MAIN); adView.setAdSize(AdSize.BANNER); //Init params RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); params.addRule(RelativeLayout.CENTER_HORIZONTAL); params.setMargins(0, 0, 0, 24); adView.setLayoutParams(params); //Add to RelativeLayout rootContainer = (RelativeLayout) view.findViewById(R.id.rootContainer); rootContainer.addView(adView); AdRequest adRequest = new AdRequest.Builder().build(); if (!DebugConfig.isDebug) adView.loadAd(adRequest); }
private void loadAd(View view) { //Init ad adView = new AdView(application); adView.setAdUnitId(ApiUtils.AD_UNIT_ID_SEARCH_USER); adView.setAdSize(AdSize.BANNER); //Init params RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); params.addRule(RelativeLayout.CENTER_HORIZONTAL); params.setMargins(0, 0, 0, 24); adView.setLayoutParams(params); //Add to container RelativeLayout rootContainer = (RelativeLayout) view.findViewById(R.id.rootContainer); rootContainer.addView(adView); //Add request AdRequest adRequest = new AdRequest.Builder().build(); if (!DebugConfig.isDebug) adView.loadAd(adRequest); }
private void loadAd(View view) { //Init ad adView = new AdView(application); adView.setAdUnitId(ApiUtils.AD_UNIT_ID_USER_PROFILE); adView.setAdSize(AdSize.BANNER); //Init params RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); params.addRule(RelativeLayout.CENTER_HORIZONTAL); params.setMargins(0, 0, 0, 24); adView.setLayoutParams(params); //Add to container RelativeLayout rootContainer = (RelativeLayout) view.findViewById(R.id.rootContainer); rootContainer.addView(adView); //Add request AdRequest adRequest = new AdRequest.Builder().build(); if (!DebugConfig.isDebug) adView.loadAd(adRequest); }
private void setupAds() { String admobAdUnitId = getString( R.string.main_activity_admob_ad_unit_id ); if ( admobAdUnitId != null && !admobAdUnitId.equals( ( "" ) ) ) { mAdView = new AdView( this ); mAdView.setAdSize( AdSize.BANNER ); mAdView.setAdUnitId( admobAdUnitId ); mAdFrame.addView( mAdView ); String[] testDeviceIds = getResources().getStringArray( R.array.admob_test_device_ids ); AdRequest.Builder adRequestBuilder = new AdRequest.Builder(); adRequestBuilder.addTestDevice( AdRequest.DEVICE_ID_EMULATOR ); for ( int i = 0; i < testDeviceIds.length; i++ ) { adRequestBuilder.addTestDevice( testDeviceIds[i] ); } AdRequest adRequest = adRequestBuilder.build(); mAdView.loadAd( adRequest ); } }
private void setupAds() { String admobAdUnitId = getString( R.string.video_activity_admob_ad_unit_id ); if ( admobAdUnitId != null && !admobAdUnitId.equals( ( "" ) ) ) { mAdView = new AdView( this ); mAdView.setAdSize( AdSize.BANNER ); mAdView.setAdUnitId( admobAdUnitId ); mAdFrame.addView( mAdView ); String[] testDeviceIds = getResources().getStringArray( R.array.admob_test_device_ids ); AdRequest.Builder adRequestBuilder = new AdRequest.Builder(); adRequestBuilder.addTestDevice( AdRequest.DEVICE_ID_EMULATOR ); for ( int i = 0; i < testDeviceIds.length; i++ ) { adRequestBuilder.addTestDevice( testDeviceIds[i] ); } AdRequest adRequest = adRequestBuilder.build(); mAdView.loadAd( adRequest ); } }
private static void displayGoogleEasyModeBanner() { if (isSmallScreen()) { initEasyModeIntersitial(); } else { Game.instance().runOnUiThread(new Runnable() { @Override public void run() { if (bannerIndex()<0) { AdView adView = new AdView(Game.instance()); adView.setAdSize(AdSize.SMART_BANNER); adView.setAdUnitId(Game.getVar(R.string.easyModeAdUnitId)); adView.setBackgroundColor(Color.TRANSPARENT); AdRequest adRequest = new AdRequest.Builder().addTestDevice(Game.getVar(R.string.testDevice)) .build(); Game.instance().getLayout().addView(adView, 0); adView.loadAd(adRequest); Game.setNeedSceneRestart(true); } } }); } }
/** * Constructor * * @param activity * @param fragmentTag */ public AdDialogHelper(FragmentActivity activity, String fragmentTag) { mActivity = activity; mFragmentTag = fragmentTag; mAdDialogFragment = new AdDialogFragment(); mAdDialogFragment.setCancelable(false); // Create the adView mAdView = new AdView(activity); mAdView.setAdUnitId(activity.getString(R.string.admob_in_game_ad_unit)); mAdView.setAdSize(AdSize.BANNER); mAdView.setAdListener(this); if (AdsHelper.shoulShowAds(activity)) { AdsHelper.requestAd(mAdView); } }
public static LinearLayout createLayoutWithAd(Activity activity) { LinearLayout layout = new LinearLayout(activity); layout.setOrientation(LinearLayout.VERTICAL); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); lp.gravity = Gravity.CENTER_HORIZONTAL; AdView goodAdv = new AdView(activity); //, com.google.ads.AdSize.BANNER, GOOGLE_AD_ID if (LiveWallpaperSettings.DEBUG) { goodAdv.setAdUnitId(""); } else { goodAdv.setAdUnitId("ca-app-pub-7879767097814866/4363554030"); } goodAdv.setAdSize(AdSize.BANNER); layout.addView(goodAdv); AdRequest.Builder builder = new Builder(); goodAdv.loadAd(builder.build()); return layout; }
/** * 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; }
protected void trySetupAdView(){ mAdViewContainer = (LinearLayout) findViewById(R.id.admob_container); if(mAdViewContainer != null){ mAdView = new AdView(this); mAdView.setAdUnitId(BuildConfig.AD_UNIT_ID); mAdView.setAdSize(AdSize.BANNER); mAdViewContainer.addView(mAdView); AdRequest.Builder builder = new AdRequest.Builder(); if(BuildConfig.DEBUG){ builder.addTestDevice(BuildConfig.AD_TEST_DEVICE_ID); } AdRequest adRequest = builder.build(); mAdView.loadAd(adRequest); } }
/** * 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.loadAd(buildRequest(ssparm, targetingParameters)); return adView; }
/** * 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 adMob this is the adUnitID * @param width Width of ad * @param height Height of 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)); adView = new AdView(activity); adView.setAdUnitId(adUnitID); adView.setAdSize(new AdSize(width, height)); adView.setAdListener(adListener); try { adView.loadAd(buildRequest(targetingParameters)); } catch (NoClassDefFoundError e) { // This can be thrown by Play Services on Honeycomb. adListener.onAdFailedToLoad(AdRequest.ERROR_CODE_NO_FILL); } return adView; }
private AdView createadmob() { AdView mAdView = new AdView(this); mAdView.setAdSize(AdSize.MEDIUM_RECTANGLE); mAdView.setAdUnitId("ca-app-pub-3940256099942544/6300978111"); mAdView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); // 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()); return mAdView; }
private void setupBannerWithoutWait() { FrameLayout adFrame = (FrameLayout) root.findViewById(R.id.adFrame); adFrame.removeAllViews(); adView1 = new PublisherAdView(getActivity()); adView1.setAdUnitId(Constants.DFP_BANNER_ADUNIT_ID_320x50); adView1.setAdSizes(new AdSize(320, 50)); adView1.setAdListener(adListener); adFrame.addView(adView1); //region PriceCheckForDFP API usage PublisherAdRequest.Builder builder = new PublisherAdRequest.Builder(); PublisherAdRequest request = builder.build(); Prebid.attachBids(request, Constants.BANNER_320x50, this.getActivity()); //endregion adView1.loadAd(request); }
private void loadNativeAd(int width, float deviceDensity) { float adWidth = width / deviceDensity; if (adWidth > MAX_WIDTH) adWidth = MAX_WIDTH; mNativeExpressAdView.setAdSize(new AdSize((int) adWidth, MIN_HEIGHT)); mNativeLoading = true; mNativeExpressAdView.loadAd(new AdRequest.Builder().build()); }