com.google.ads.AdRequest Java Examples
The following examples show how to use
com.google.ads.AdRequest.
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: GodotAdMob.java From godot_modules with MIT License | 6 votes |
public void ShowInterstitialUIThread() { if (initialized) { // Create ad request AdRequest adRequest = new AdRequest(); // Begin loading your interstitial interstitial.loadAd(adRequest); // Set Ad Listener to use the callbacks below interstitial.setAdListener((AdListener) this); adReceived = false; screenDismissed = false; failedToReceiveAd = false; applicationLeaved = false; presentScreen = false; Log.d("godot", "AdMob: Show Interstitial"); } else { Log.e("godot", "AdMob: Calling \"ShowInterstitial()\" but AdMob not initilized"); } }
Example #2
Source File: PhotosActivity.java From android-discourse with Apache License 2.0 | 5 votes |
private void setupAds() { // Create an ad. interstitialAd = new InterstitialAd(this, "a151e7d92c31de5"); // Set the AdListener. interstitialAd.setAdListener(this); // Load the interstitial ad. Check logcat output for the hashed // device ID // to get test ads on a physical device. AdRequest adRequest = new AdRequest(); adRequest.addTestDevice(AdRequest.TEST_EMULATOR); adRequest.addTestDevice("F324042096EAD64362E1164ACEA57782"); interstitialAd.loadAd(adRequest); }
Example #3
Source File: AdmobBanner.java From Klyph with MIT License | 5 votes |
@Override public void loadAd(View adView) { AdRequest ar = new AdRequest(); if (BannerAdManager.getTargetingBirthday() != BannerAdManager.NONE) { Date date = new Date(); date.setTime(BannerAdManager.getTargetingBirthday()); ar.setBirthday(date); } ((AdView) adView).loadAd(new AdRequest()); }
Example #4
Source File: GodotAdMob.java From godot_modules with MIT License | 5 votes |
public void ShowBannerUIThread() { if (initialized) { AdRequest request = new AdRequest(); adView.loadAd(request); adView.setVisibility(View.VISIBLE); Log.d("godot", "AdMob: Show Banner"); } else { Log.e("godot", "AdMob: Calling \"ShowBanner()\" but AdMob not initilized"); } }
Example #5
Source File: LegacyAdMobBanner.java From mobile-sdk-android with Apache License 2.0 | 5 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 3d 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 the ad * @param height Height of the ad */ @Override public View requestAd(MediatedBannerAdViewController mBC, Activity activity, String parameter, String adUnitID, int width, int height, TargetingParameters targetingParameters) { adListener = new AdMobAdListener(mBC, super.getClass().getSimpleName()); adListener.printToClog(String.format(" - requesting an ad: [%s, %s, %dx%d]", parameter, adUnitID, width, height)); admobAV = new AdView(activity, new AdSize(width, height), adUnitID); admobAV.setAdListener(adListener); AdRequest ar = new AdRequest(); switch (targetingParameters.getGender()) { case UNKNOWN: break; case FEMALE: ar.setGender(AdRequest.Gender.FEMALE); break; case MALE: ar.setGender(AdRequest.Gender.MALE); break; } AdMobAdapterExtras extras = new AdMobAdapterExtras(); if (targetingParameters.getAge() != null) { extras.addExtra("Age", targetingParameters.getAge()); } for (Pair<String, String> p : targetingParameters.getCustomKeywords()) { extras.addExtra(p.first, p.second); } if (targetingParameters.getLocation() != null) { ar.setLocation(targetingParameters.getLocation()); } ar.setNetworkExtras(extras); admobAV.loadAd(ar); return admobAV; }
Example #6
Source File: LegacyAdMobInterstitial.java From mobile-sdk-android with Apache License 2.0 | 5 votes |
@Override public void requestAd(MediatedInterstitialAdViewController mIC, Activity activity, String parameter, String uid, TargetingParameters targetingParameters) { adListener = new AdMobAdListener(mIC, super.getClass().getSimpleName()); adListener.printToClog(String.format("requesting an ad: [%s, %s]", parameter, uid)); iad = new InterstitialAd(activity, uid); AdRequest ar = new AdRequest(); switch (targetingParameters.getGender()) { case UNKNOWN: break; case FEMALE: ar.setGender(AdRequest.Gender.FEMALE); break; case MALE: ar.setGender(AdRequest.Gender.MALE); break; } AdMobAdapterExtras extras = new AdMobAdapterExtras(); if (targetingParameters.getAge() != null) { extras.addExtra("Age", targetingParameters.getAge()); } for (Pair<String, String> p : targetingParameters.getCustomKeywords()) { extras.addExtra(p.first, p.second); } ar.setNetworkExtras(extras); if (targetingParameters.getLocation() != null) { ar.setLocation(targetingParameters.getLocation()); } iad.setAdListener(adListener); iad.loadAd(ar); }
Example #7
Source File: AdMobAdListener.java From mobile-sdk-android with Apache License 2.0 | 5 votes |
@Override public void onFailedToReceiveAd(Ad ad, AdRequest.ErrorCode errorCode) { printToClog("onFailedToReceiveAd: " + ad + " error code: " + errorCode); ResultCode code = ResultCode.INTERNAL_ERROR; switch (errorCode) { case INTERNAL_ERROR: code = ResultCode.INTERNAL_ERROR; break; case INVALID_REQUEST: code = ResultCode.INVALID_REQUEST; break; case NETWORK_ERROR: code = ResultCode.NETWORK_ERROR; break; case NO_FILL: code = ResultCode.UNABLE_TO_FILL; break; default: break; } if (mediatedAdViewController != null) { mediatedAdViewController.onAdFailed(code); } }
Example #8
Source File: LegacyDFPInterstitial.java From mobile-sdk-android with Apache License 2.0 | 5 votes |
@Override public void requestAd(MediatedInterstitialAdViewController mIC, Activity activity, String parameter, String uid, TargetingParameters targetingParameters) { adListener = new AdMobAdListener(mIC, super.getClass().getSimpleName()); adListener.printToClog(String.format("requesting an ad: [%s, %s]", parameter, uid)); iad = new InterstitialAd(activity, uid); AdRequest ar = new AdRequest(); switch (targetingParameters.getGender()) { case UNKNOWN: break; case FEMALE: ar.setGender(AdRequest.Gender.FEMALE); break; case MALE: ar.setGender(AdRequest.Gender.MALE); break; } DfpExtras extras = new DfpExtras(); if (targetingParameters.getAge() != null) { extras.addExtra("Age", targetingParameters.getAge()); } if (targetingParameters.getLocation() != null) { ar.setLocation(targetingParameters.getLocation()); } for (Pair<String, String> p : targetingParameters.getCustomKeywords()) { extras.addExtra(p.first, p.second); } ar.setNetworkExtras(extras); iad.setAdListener(adListener); iad.loadAd(ar); }
Example #9
Source File: AdmobBanner.java From KlyphMessenger with MIT License | 4 votes |
@Override public void loadAd(View adView) { ((AdView) adView).loadAd(new AdRequest()); }
Example #10
Source File: LegacyDFPBanner.java From mobile-sdk-android with Apache License 2.0 | 4 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 3d 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 */ @Override public View requestAd(MediatedBannerAdViewController mBC, Activity activity, String parameter, String adUnitID, int width, int height, TargetingParameters targetingParameters) { adListener = new AdMobAdListener(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); if (ssparm.isSwipeable) { dfpView = new SwipeableDfpAdView(activity, adSize, adUnitID); } else { dfpView = new DfpAdView(activity, adSize, adUnitID); } dfpView.setAdListener(adListener); AdRequest ar = new AdRequest(); if (ssparm.test_device != null && ssparm.test_device.length() > 0) { adListener.printToClog("requestAd called with test device " + ssparm.test_device); ar.addTestDevice(ssparm.test_device); } switch (targetingParameters.getGender()) { case UNKNOWN: break; case FEMALE: ar.setGender(AdRequest.Gender.FEMALE); break; case MALE: ar.setGender(AdRequest.Gender.MALE); break; } DfpExtras extras = new DfpExtras(); if (targetingParameters.getAge() != null) { extras.addExtra("Age", targetingParameters.getAge()); } if (targetingParameters.getLocation() != null) { ar.setLocation(targetingParameters.getLocation()); } for (Pair<String, String> p : targetingParameters.getCustomKeywords()) { extras.addExtra(p.first, p.second); } ar.setNetworkExtras(extras); dfpView.loadAd(ar); return dfpView; }