/** * 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 }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_my); // Gets the ad view defined in layout/ad_fragment.xml with ad unit ID set in // values/strings.xml. mAdView = findViewById(R.id.ad_view); // Create an ad request. Check logcat output for the hashed device ID to // get test ads on a physical device. e.g. // "Use AdRequest.Builder.addTestDevice("ABCDEF012345") to get test ads on this device." PublisherAdRequest adRequest = new PublisherAdRequest.Builder().build(); // Start loading the ad in the background. mAdView.loadAd(adRequest); }
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mNoExclusionsAdView = getView().findViewById(R.id.no_exclusions_av); mDogsExcludedAdView = getView().findViewById(R.id.exclusions_av_dogsexcluded); mCatsExcludedAdView = getView().findViewById(R.id.exclusions_av_catsexcluded); PublisherAdRequest noExclusionsRequest = new PublisherAdRequest.Builder().build(); PublisherAdRequest dogsExcludedRequest = new PublisherAdRequest.Builder() .addCategoryExclusion(getString(R.string.categoryexclusion_dogscategoryname)) .build(); PublisherAdRequest catsExcludedRequest = new PublisherAdRequest.Builder() .addCategoryExclusion(getString(R.string.categoryexclusion_catscategoryname)) .build(); mNoExclusionsAdView.loadAd(noExclusionsRequest); mDogsExcludedAdView.loadAd(dogsExcludedRequest); mCatsExcludedAdView.loadAd(catsExcludedRequest); }
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mUsernameEditText = getView().findViewById(R.id.ppid_et_username); mLoadAdButton = getView().findViewById(R.id.ppid_btn_loadad); mPublisherAdView = getView().findViewById(R.id.ppid_pav_main); mLoadAdButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { String username = mUsernameEditText.getText().toString(); if (username.length() == 0) { Toast.makeText(DFPPPIDFragment.this.getActivity(), "The username cannot be empty", Toast.LENGTH_SHORT).show(); } else { String ppid = generatePPID(username); PublisherAdRequest request = new PublisherAdRequest.Builder() .setPublisherProvidedId(ppid) .build(); mPublisherAdView.loadAd(request); } } }); }
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mSportsSpinner = getView().findViewById(R.id.customtargeting_spn_sport); mLoadButton = getView().findViewById(R.id.customtargeting_btn_loadad); mAdView = getView().findViewById(R.id.customtargeting_av_main); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getView().getContext(), R.array.customtargeting_sports, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mSportsSpinner.setAdapter(adapter); mLoadButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { PublisherAdRequest adRequest = new PublisherAdRequest.Builder() .addCustomTargeting(getString(R.string.customtargeting_key), (String) mSportsSpinner.getSelectedItem()) .build(); mAdView.loadAd(adRequest); } }); }
@Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); root = inflater.inflate(R.layout.fragment_interstitial, null); // interstitial set up mPublisherInterstitialAd = new PublisherInterstitialAd(getContext()); mPublisherInterstitialAd.setAdUnitId(Constants.DFP_INTERSTITIAL_ADUNIT_ID_FULLSCREEN); mPublisherInterstitialAd.setAdListener(new AdListener() { @Override public void onAdFailedToLoad(int i) { super.onAdFailedToLoad(i); if (i == AdRequest.ERROR_CODE_INTERNAL_ERROR) { LogUtil.e("DFP", "Interstitial Ad failed to load internal error"); } else if (i == AdRequest.ERROR_CODE_INVALID_REQUEST) { LogUtil.e("DFP", "Interstitial Ad failed to load internal error"); } else if (i == AdRequest.ERROR_CODE_NETWORK_ERROR) { LogUtil.e("DFP", "Interstitial Ad failed to load network error"); } else if (i == AdRequest.ERROR_CODE_NO_FILL) { LogUtil.e("DFP", "Interstitial Ad failed to load no fill"); } } @Override public void onAdLoaded() { super.onAdLoaded(); mPublisherInterstitialAd.show(); } }); request = new PublisherAdRequest.Builder().build(); Button btnLoad = (Button) root.findViewById(R.id.loadInterstitial); btnLoad.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { loadInterstitial(v); } }); return root; }
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); }
@Override public void onAttachComplete(Object adObj) { if (adView2 != null && adObj != null && adObj instanceof PublisherAdRequest) { adView2.loadAd((PublisherAdRequest) adObj); Prebid.detachUsedBid(adObj); } }
private void getBanner(String iu){ final PublisherAdView adView = new PublisherAdView(getContext()); adView.setAdUnitId(iu); adView.setAdSizes(AdSize.SMART_BANNER); AdListener mAdListener = new AdListener() { @Override public void onAdClosed() { super.onAdClosed(); } @Override public void onAdFailedToLoad(int errorCode) { super.onAdFailedToLoad(errorCode); } @Override public void onAdLeftApplication() { super.onAdLeftApplication(); } @Override public void onAdOpened() { super.onAdOpened(); } @Override public void onAdLoaded() { super.onAdLoaded(); bannerContainer.addView(adView); } }; adView.setAdListener(mAdListener); PublisherAdRequest adRequest = new PublisherAdRequest.Builder().build(); adView.loadAd(adRequest); }
private void getPopup(String adCode){ final PublisherInterstitialAd interstitialAd = new PublisherInterstitialAd(getActivity()); interstitialAd.setAdUnitId(adCode); interstitialAd.setAdListener(new AdListener() { @Override public void onAdClosed() { } @Override public void onAdLoaded() { interstitialAd.show(); } @Override public void onAdFailedToLoad(int errorCode) { } @Override public void onAdLeftApplication() { super.onAdLeftApplication(); } @Override public void onAdOpened() { super.onAdOpened(); } }); PublisherAdRequest adRequest = new PublisherAdRequest.Builder().build(); interstitialAd.loadAd(adRequest); }
private void startGame() { // Request a new ad if one isn't already loaded, hide the button, and kick off the timer. if (!mAdIsLoading && !mInterstitialAd.isLoaded()) { mAdIsLoading = true; PublisherAdRequest adRequest = new PublisherAdRequest.Builder().build(); mInterstitialAd.loadAd(adRequest); } mRetryButton.setVisibility(View.INVISIBLE); resumeGame(GAME_LENGTH_MILLISECONDS); }
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mAdView = getView().findViewById(R.id.appevents_av_main); mAdView.setAppEventListener(new AppEventListener() { @Override public void onAppEvent(String name, String data) { // The DFP ad that this fragment loads contains JavaScript code that sends App // Events to the host application. This AppEventListener receives those events, // and sets the background of the fragment to match the data that comes in. // The ad will send "red" when it loads, "blue" five seconds later, and "green" // if the user taps the ad. // This is just a demonstration, of course. Your apps can do much more interesting // things with App Events. if (name.equals("color")) { switch (data) { case "blue": mRootView.setBackgroundColor(Color.rgb(0xD0, 0xD0, 0xFF)); break; case "red": mRootView.setBackgroundColor(Color.rgb(0xFF, 0xD0, 0xD0)); break; case "green": mRootView.setBackgroundColor(Color.rgb(0xD0, 0xFF, 0xD0)); break; } } } }); PublisherAdRequest adRequest = new PublisherAdRequest.Builder().build(); mAdView.loadAd(adRequest); }
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // The size for this PublisherAdView is defined in the XML layout as AdSize.FLUID. It could // also be set here by calling mPublisherAdView.setAdSizes(AdSize.FLUID). // // An ad with fluid size will automatically stretch or shrink to fit the height of its // content, which can help layout designers cut down on excess whitespace. mPublisherAdView = getView().findViewById(R.id.fluid_av_main); PublisherAdRequest publisherAdRequest = new PublisherAdRequest.Builder().build(); mPublisherAdView.loadAd(publisherAdRequest); mChangeAdViewWidthButton = getView().findViewById(R.id.fluid_btn_change_width); mChangeAdViewWidthButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { int newWidth = mAdViewWidths[mCurrentIndex % mAdViewWidths.length]; mCurrentIndex += 1; // Change the PublisherAdView's width. ViewGroup.LayoutParams layoutParams = mPublisherAdView.getLayoutParams(); final float scale = getResources().getDisplayMetrics().density; layoutParams.width = (int) (newWidth * scale + 0.5f); mPublisherAdView.setLayoutParams(layoutParams); // Update the TextView with the new width. mCurrentWidthTextView = getView().findViewById(R.id.fluid_tv_current_width); mCurrentWidthTextView.setText( String.format(Locale.getDefault(), "%d dp", newWidth)); } }); }
/** * Loads a {@link NativeContentAd} and calls {@link ContentAdViewHolder} methods to * display its assets or handle failure by hiding the view. */ public void loadAd(Context context, ContentAdViewHolder viewHolder) { synchronized (mSyncObject) { mViewHolder = viewHolder; if ((mAdLoader != null) && mAdLoader.isLoading()) { Log.d(MainActivity.LOG_TAG, "ContentAdFetcher is already loading an ad."); return; } // If an ad previously loaded, reuse it instead of requesting a new one. if (mContentAd != null) { mViewHolder.populateView(mContentAd); return; } NativeContentAd.OnContentAdLoadedListener contentAdListener = new NativeContentAd.OnContentAdLoadedListener() { public void onContentAdLoaded(NativeContentAd ad) { mContentAd = ad; mViewHolder.populateView(mContentAd); } }; if (mAdLoader == null) { mAdLoader = new AdLoader.Builder(context, mAdUnitId) .forContentAd(contentAdListener) .withAdListener(new AdListener() { @Override public void onAdFailedToLoad(int errorCode) { mViewHolder.hideView(); Log.e(MainActivity.LOG_TAG, "Content Ad Failed to load: " + errorCode); } }).build(); } mAdLoader.loadAd(new PublisherAdRequest.Builder().build()); } }
public void loadBanner() { ArrayList<AdSize> adSizes = new ArrayList<AdSize>(); if (this.adSize != null) { adSizes.add(this.adSize); } if (this.validAdSizes != null) { for (int i = 0; i < this.validAdSizes.length; i++) { adSizes.add(this.validAdSizes[i]); } } if (adSizes.size() == 0) { adSizes.add(AdSize.BANNER); } AdSize[] adSizesArray = adSizes.toArray(new AdSize[adSizes.size()]); this.adView.setAdSizes(adSizesArray); PublisherAdRequest.Builder adRequestBuilder = new PublisherAdRequest.Builder(); if (testDevices != null) { for (int i = 0; i < testDevices.length; i++) { adRequestBuilder.addTestDevice(testDevices[i]); } } PublisherAdRequest adRequest = adRequestBuilder.build(); this.adView.loadAd(adRequest); }
@Nullable @Override public Map<String, Object> getExportedViewConstants() { final Map<String, Object> constants = new HashMap<>(); constants.put("simulatorId", PublisherAdRequest.DEVICE_ID_EMULATOR); return constants; }
private PublisherAdRequest buildRequest(DFBBannerSSParameters ssparm, TargetingParameters targetingParameters) { PublisherAdRequest.Builder builder = new PublisherAdRequest.Builder(); if ((ssparm.test_device != null) && (ssparm.test_device.length() > 0)) { adListener.printToClog("test device " + ssparm.test_device); builder.addTestDevice(ssparm.test_device); } switch (targetingParameters.getGender()) { case UNKNOWN: builder.setGender(PublisherAdRequest.GENDER_UNKNOWN); break; case FEMALE: builder.setGender(PublisherAdRequest.GENDER_FEMALE); break; case MALE: builder.setGender(PublisherAdRequest.GENDER_MALE); break; } Bundle bundle = new Bundle(); if (targetingParameters.getAge() != null) { bundle.putString("Age", targetingParameters.getAge()); } if (targetingParameters.getLocation() != null) { builder.setLocation(targetingParameters.getLocation()); } for (Pair<String, String> p : targetingParameters.getCustomKeywords()) { bundle.putString(p.first, p.second); } builder.addNetworkExtras(new AdMobExtras(bundle)); return builder.build(); }
private PublisherAdRequest buildRequest(TargetingParameters targetingParameters) { PublisherAdRequest.Builder builder = new PublisherAdRequest.Builder(); switch (targetingParameters.getGender()) { case UNKNOWN: builder.setGender(PublisherAdRequest.GENDER_UNKNOWN); break; case FEMALE: builder.setGender(PublisherAdRequest.GENDER_FEMALE); break; case MALE: builder.setGender(PublisherAdRequest.GENDER_MALE); break; } Bundle bundle = new Bundle(); if (targetingParameters.getAge() != null) { bundle.putString("Age", targetingParameters.getAge()); } if (targetingParameters.getLocation() != null) { builder.setLocation(targetingParameters.getLocation()); } for (Pair<String, String> p : targetingParameters.getCustomKeywords()) { bundle.putString(p.first, p.second); } builder.addNetworkExtras(new AdMobExtras(bundle)); return builder.build(); }
@NonNull @Override public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) { // Get the data item for this position String item = getItem(position); // Check if an existing view is being reused, otherwise inflate the view if (convertView == null) { convertView = LayoutInflater.from(getContext()).inflate(R.layout.listitem_mediation_banner, parent, false); } // Lookup view for data population TextView adCode = convertView.findViewById(R.id.adcode); final ViewGroup bannerContainer = convertView.findViewById(R.id.banner_view); // Populate the data into the template view using the data object adCode.setText(item); if (bannerContainer.getChildCount() == 0) { final PublisherAdView adView = new PublisherAdView(getContext()); adView.setAdUnitId(item); adView.setAdSizes(AdSize.SMART_BANNER); AdListener mAdListener = new AdListener() { @Override public void onAdClosed() { super.onAdClosed(); } @Override public void onAdFailedToLoad(int errorCode) { super.onAdFailedToLoad(errorCode); } @Override public void onAdLeftApplication() { super.onAdLeftApplication(); } @Override public void onAdOpened() { super.onAdOpened(); } @Override public void onAdLoaded() { super.onAdLoaded(); bannerContainer.addView(adView); } }; adView.setAdListener(mAdListener); PublisherAdRequest adRequest = new PublisherAdRequest.Builder().build(); adView.loadAd(adRequest); } // Return the completed view to render on screen return convertView; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_play); AdView adView = (AdView)this.findViewById(R.id.adView); AdRequest adRequest = new AdRequest.Builder() .build(); adView.loadAd(adRequest); interstitial = new PublisherInterstitialAd(this); interstitial.setAdUnitId("ca-app-pub-7166295480563138/3626215601"); adRequestI = new PublisherAdRequest.Builder().build(); interstitial.loadAd(adRequestI); SharedPreferences pre = getSharedPreferences("mynew", MODE_PRIVATE); inert=pre.getInt("ads", inert); SharedPreferences shared = getSharedPreferences("mynew", Context.MODE_PRIVATE); Editor editors = shared.edit(); if(inert==201) inert=0; //for ads inert++; editors.putInt("ads", inert); editors.commit(); Typeface face = Typeface.createFromAsset(getAssets(),"font1.ttf"); back=new Random(); sl=false; bg=(RelativeLayout)findViewById(R.id.base); int ran = back.nextInt(7-1)+1+1; Log.v("color",""+ran); bg.getBackground().setColorFilter(Color.parseColor(colors[ran]), PorterDuff.Mode.SRC); s=false; word=new words(); tv = (TextView)findViewById(R.id.textView1); sc = (TextView)findViewById(R.id.textView2); tv.setTypeface(face); sc.setTypeface(face); drop_layout = (LinearLayout)findViewById(R.id.drop); yesbut=(Button)findViewById(R.id.yesbut); nobut=(Button)findViewById(R.id.nobut); tv1=(TextView)findViewById(R.id.tv11); tv2=(TextView)findViewById(R.id.tv22); pb=(ProgressBar)findViewById(R.id.progressbar); mp = MediaPlayer.create(getApplicationContext(), R.raw.sound); Resources res = getResources(); Drawable drawable = res.getDrawable(R.drawable.background); pb.setProgress(2500); // Main Progress pb.setSecondaryProgress(5000);// Secondary Progress pb.setMax(10000); pb.setProgressDrawable(drawable); animation = ObjectAnimator.ofInt(pb, "progress",10000,5000,2500,0); animation.setDuration(1100); pb.setProgress(10000); slidel = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.slide_left); call(); repeat(); }
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mLoadButton = getView().findViewById(R.id.adsizes_btn_loadad); m120x20CheckBox = getView().findViewById(R.id.adsizes_cb_120x20); m320x50CheckBox = getView().findViewById(R.id.adsizes_cb_320x50); m300x250CheckBox = getView().findViewById(R.id.adsizes_cb_300x250); mPublisherAdView = getView().findViewById(R.id.adsizes_pav_main); mPublisherAdView.setAdListener(new AdListener() { @Override public void onAdLoaded() { mPublisherAdView.setVisibility(View.VISIBLE); } }); mLoadButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (!m120x20CheckBox.isChecked() && !m320x50CheckBox.isChecked() && !m300x250CheckBox.isChecked()) { Toast.makeText(DFPMultipleAdSizesFragment.this.getActivity(), "At least one size is required.", Toast.LENGTH_SHORT).show(); } else { List<AdSize> sizeList = new ArrayList<>(); if (m120x20CheckBox.isChecked()) { sizeList.add(new AdSize(120, 20)); } if (m320x50CheckBox.isChecked()) { sizeList.add(AdSize.BANNER); } if (m300x250CheckBox.isChecked()) { sizeList.add(AdSize.MEDIUM_RECTANGLE); } mPublisherAdView.setVisibility(View.INVISIBLE); mPublisherAdView.setAdSizes(sizeList.toArray(new AdSize[sizeList.size()])); mPublisherAdView.loadAd(new PublisherAdRequest.Builder().build()); } } }); }
/** * Loads a {@link NativeAppInstallAd} and calls {@link AppInstallAdViewHolder} methods to * display its assets or handle failure by hiding the view. */ public void loadAd(Context context, AppInstallAdViewHolder viewHolder) { synchronized (mSyncObject) { mViewHolder = viewHolder; if ((mAdLoader != null) && mAdLoader.isLoading()) { Log.d(MainActivity.LOG_TAG, "AppInstallAdFetcher is already loading an ad."); return; } // If an ad previously loaded, reuse it instead of requesting a new one. if (mAppInstallAd != null) { mViewHolder.populateView(mAppInstallAd); return; } NativeAppInstallAd.OnAppInstallAdLoadedListener appInstallAdListener = new NativeAppInstallAd.OnAppInstallAdLoadedListener() { public void onAppInstallAdLoaded(NativeAppInstallAd ad) { mAppInstallAd = ad; mViewHolder.populateView(mAppInstallAd); } }; if (mAdLoader == null) { mAdLoader = new AdLoader.Builder(context, mAdUnitId) .forAppInstallAd(appInstallAdListener) .withAdListener(new AdListener() { @Override public void onAdFailedToLoad(int errorCode) { mViewHolder.hideView(); Log.e(MainActivity.LOG_TAG, "App Install Ad Failed to load: " + errorCode); } }).build(); } mAdLoader.loadAd(new PublisherAdRequest.Builder().build()); } }
private void createAdView() { if (this.adView != null) this.adView.destroy(); final Context context = getContext(); this.adView = new PublisherAdView(context); this.adView.setAppEventListener(this); this.adView.setAdListener(new AdListener() { @Override public void onAdLoaded() { int width = adView.getAdSize().getWidthInPixels(context); int height = adView.getAdSize().getHeightInPixels(context); int left = adView.getLeft(); int top = adView.getTop(); adView.measure(width, height); adView.layout(left, top, left + width, top + height); sendOnSizeChangeEvent(); sendEvent(RNPublisherBannerViewManager.EVENT_AD_LOADED, null); } @Override public void onAdFailedToLoad(int errorCode) { String errorMessage = "Unknown error"; switch (errorCode) { case PublisherAdRequest.ERROR_CODE_INTERNAL_ERROR: errorMessage = "Internal error, an invalid response was received from the ad server."; break; case PublisherAdRequest.ERROR_CODE_INVALID_REQUEST: errorMessage = "Invalid ad request, possibly an incorrect ad unit ID was given."; break; case PublisherAdRequest.ERROR_CODE_NETWORK_ERROR: errorMessage = "The ad request was unsuccessful due to network connectivity."; break; case PublisherAdRequest.ERROR_CODE_NO_FILL: errorMessage = "The ad request was successful, but no ad was returned due to lack of ad inventory."; break; } WritableMap event = Arguments.createMap(); WritableMap error = Arguments.createMap(); error.putString("message", errorMessage); event.putMap("error", error); sendEvent(RNPublisherBannerViewManager.EVENT_AD_FAILED_TO_LOAD, event); } @Override public void onAdOpened() { sendEvent(RNPublisherBannerViewManager.EVENT_AD_OPENED, null); } @Override public void onAdClosed() { sendEvent(RNPublisherBannerViewManager.EVENT_AD_CLOSED, null); } @Override public void onAdLeftApplication() { sendEvent(RNPublisherBannerViewManager.EVENT_AD_LEFT_APPLICATION, null); } }); this.addView(this.adView); }
private void requestNewInterstitial() { PublisherAdRequest adRequest = new PublisherAdRequest.Builder() .build(); mPublisherInterstitialAd.loadAd(adRequest); }
private void loadRewardedVideoAd() { if (!mRewardedVideoAd.isLoaded()) { mRewardedVideoAd.loadAd(AD_UNIT_ID, new PublisherAdRequest.Builder().build()); } }