com.google.android.gms.ads.AdRequest Java Examples
The following examples show how to use
com.google.android.gms.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: RuleListAdapter.java From FwdPortForwardingApp with GNU General Public License v3.0 | 6 votes |
public AdViewHolder(View v) { super(v); AdRequest request = new AdRequest.Builder() .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .build(); AdView adView = new AdView(v.getContext()); adView.setAdSize(AdSize.SMART_BANNER); // 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); }
Example #2
Source File: InMobiAdapter.java From googleads-mobile-android-mediation with Apache License 2.0 | 6 votes |
/** * Converts a {@link com.inmobi.ads.InMobiAdRequestStatus.StatusCode} to Google Mobile Ads SDK * readable error code. * * @param statusCode the {@link com.inmobi.ads.InMobiAdRequestStatus.StatusCode} to be converted. * @return an {@link AdRequest} error code. */ private static int getAdRequestErrorCode(InMobiAdRequestStatus.StatusCode statusCode) { switch (statusCode) { case INTERNAL_ERROR: return AdRequest.ERROR_CODE_INTERNAL_ERROR; case AD_ACTIVE: case REQUEST_INVALID: case REQUEST_PENDING: case EARLY_REFRESH_REQUEST: case MISSING_REQUIRED_DEPENDENCIES: return AdRequest.ERROR_CODE_INVALID_REQUEST; case REQUEST_TIMED_OUT: case NETWORK_UNREACHABLE: return AdRequest.ERROR_CODE_NETWORK_ERROR; case NO_FILL: case SERVER_ERROR: case AD_NO_LONGER_AVAILABLE: case NO_ERROR: default: return AdRequest.ERROR_CODE_NO_FILL; } }
Example #3
Source File: GooglePlayServicesInterstitial.java From mobile-sdk-android with Apache License 2.0 | 6 votes |
@Override public void requestAd(MediatedInterstitialAdViewController mIC, Activity activity, String parameter, String adUnitId, TargetingParameters targetingParameters) { adListener = new GooglePlayAdListener(mIC, super.getClass().getSimpleName()); adListener.printToClog(String.format(" - requesting an ad: [%s, %s]", parameter, adUnitId)); interstitialAd = new InterstitialAd(activity); interstitialAd.setAdUnitId(adUnitId); interstitialAd.setAdListener(adListener); try { interstitialAd.loadAd(buildRequest(targetingParameters)); } catch (NoClassDefFoundError e) { // This can be thrown by Play Services on Honeycomb. adListener.onAdFailedToLoad(AdRequest.ERROR_CODE_NO_FILL); } }
Example #4
Source File: InterstitialAdActivity.java From Instagram-Profile-Downloader with MIT License | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_interstitial_ad); mInterstitialAd = new InterstitialAd(this); // set the ad unit ID mInterstitialAd.setAdUnitId("ca-app-pub-7814549536543810/9305872827"); AdRequest adRequest = new AdRequest.Builder() .build(); // Load ads into Interstitial Ads mInterstitialAd.loadAd(adRequest); mInterstitialAd.setAdListener(new AdListener() { public void onAdLoaded() { showInterstitial(); } }); }
Example #5
Source File: AdUtils.java From android-gradle-java-app-template with Apache License 2.0 | 6 votes |
@NonNull public static String getErrorReason(@IntRange(from = AdRequest.ERROR_CODE_INTERNAL_ERROR, to = AdRequest.ERROR_CODE_NO_FILL) int errorCode) { switch (errorCode) { default: case AdRequest.ERROR_CODE_INTERNAL_ERROR: return "Internal Error"; case AdRequest.ERROR_CODE_INVALID_REQUEST: return "Invalid Request"; case AdRequest.ERROR_CODE_NETWORK_ERROR: return "Network Error"; case AdRequest.ERROR_CODE_NO_FILL: return "No Fill"; } }
Example #6
Source File: AdapterHelper.java From googleads-mobile-android-mediation with Apache License 2.0 | 6 votes |
/** * Convert i-mobile fail reason to AdMob error code. * * @param reason i-mobile fail reason * @return AdMob error code */ public static int convertToAdMobErrorCode(FailNotificationReason reason) { // Convert i-mobile fail reason to AdMob error code. switch (reason) { case RESPONSE: case UNKNOWN: return AdRequest.ERROR_CODE_INTERNAL_ERROR; case PARAM: case AUTHORITY: case PERMISSION: return AdRequest.ERROR_CODE_INVALID_REQUEST; case NETWORK_NOT_READY: case NETWORK: return AdRequest.ERROR_CODE_NETWORK_ERROR; case AD_NOT_READY: case NOT_DELIVERY_AD: case SHOW_TIMEOUT: return AdRequest.ERROR_CODE_NO_FILL; default: return AdRequest.ERROR_CODE_INTERNAL_ERROR; } }
Example #7
Source File: MainActivityFragment.java From ud867 with MIT License | 6 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View root = inflater.inflate(R.layout.fragment_main, container, false); AdView mAdView = (AdView) root.findViewById(R.id.adView); // 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." AdRequest adRequest = new AdRequest.Builder() .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .build(); mAdView.loadAd(adRequest); return root; }
Example #8
Source File: AbstractExecutor.java From cordova-plugin-admob-free with MIT License | 6 votes |
/** * Gets a string error reason from an error code. */ public static String getErrorReason(int errorCode) { String errorReason = ""; switch (errorCode) { case AdRequest.ERROR_CODE_INTERNAL_ERROR: errorReason = "Internal error"; break; case AdRequest.ERROR_CODE_INVALID_REQUEST: errorReason = "Invalid request"; break; case AdRequest.ERROR_CODE_NETWORK_ERROR: errorReason = "Network Error"; break; case AdRequest.ERROR_CODE_NO_FILL: errorReason = "No fill"; break; } return errorReason; }
Example #9
Source File: SampleMediationInterstitialEventForwarder.java From googleads-mobile-android-mediation with Apache License 2.0 | 6 votes |
@Override public void onAdFetchFailed(SampleErrorCode errorCode) { switch (errorCode) { case UNKNOWN: mediationListener.onAdFailedToLoad(adapter, AdRequest.ERROR_CODE_INTERNAL_ERROR); break; case BAD_REQUEST: mediationListener.onAdFailedToLoad(adapter, AdRequest.ERROR_CODE_INVALID_REQUEST); break; case NETWORK_ERROR: mediationListener.onAdFailedToLoad(adapter, AdRequest.ERROR_CODE_NETWORK_ERROR); break; case NO_INVENTORY: mediationListener.onAdFailedToLoad(adapter, AdRequest.ERROR_CODE_NO_FILL); break; } }
Example #10
Source File: SearchActivity.java From aMuleRemote with GNU General Public License v3.0 | 6 votes |
@Override public void onCreate(Bundle savedInstanceState) { mApp = (AmuleRemoteApplication) getApplication(); if (DEBUG) Log.d(TAG, "SearchActivity.onCreate: Calling super"); super.onCreate(savedInstanceState); if (DEBUG) Log.d(TAG, "SearchActivity.onCreate: Back from super"); if (DEBUG) Log.d(TAG, "SearchActivity.onCreate: Calling setContentView"); setContentView(R.layout.act_search); if (DEBUG) Log.d(TAG, "SearchActivity.onCreate: Back from setContentView"); getSupportActionBar().setTitle(R.string.search_title); getSupportActionBar().setDisplayHomeAsUpEnabled(true); mFragManager = getSupportFragmentManager(); AdView adView = (AdView)this.findViewById(R.id.adView); AdRequest adRequest = new AdRequest.Builder() .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .addTestDevice("TEST_DEVICE_ID") .build(); adView.loadAd(adRequest); }
Example #11
Source File: AdMobPlugin.java From cordova-admob-pro with MIT License | 6 votes |
@Override protected Object __prepareRewardVideoAd(String adId) { // safety check to avoid exceptoin in case adId is null or empty if(adId==null || adId.length()==0) adId = TEST_REWARDVIDEO_ID; RewardedVideoAd ad = MobileAds.getRewardedVideoAdInstance(getActivity()); ad.setRewardedVideoAdListener(new RewardVideoListener()); synchronized (mLock) { if (!mIsRewardedVideoLoading) { mIsRewardedVideoLoading = true; Bundle extras = new Bundle(); extras.putBoolean("_noRefresh", true); AdRequest adRequest = new AdRequest.Builder() .addNetworkExtrasBundle(AdMobAdapter.class, extras) .build(); ad.loadAd(adId, adRequest); } } return ad; }
Example #12
Source File: NativeVideoAdLoader.java From googleads-mobile-android-mediation with Apache License 2.0 | 6 votes |
NativeVideoAdLoader( NendNativeAdForwarder forwarder, AdUnitMapper mapper, NativeMediationAdRequest nativeMediationAdRequest, Bundle mediationExtras) { Context context = forwarder.getContextFromWeakReference(); if (context == null) { Log.e(TAG, "Your context may be released..."); forwarder.failedToLoad(AdRequest.ERROR_CODE_INVALID_REQUEST); return; } this.forwarder = forwarder; NendAdNativeVideo.VideoClickOption clickOption = NendAdNativeVideo.VideoClickOption.LP; VideoOptions nativeVideoOptions = nativeMediationAdRequest.getNativeAdOptions().getVideoOptions(); if (nativeVideoOptions != null && nativeVideoOptions.getClickToExpandRequested()) { clickOption = NendAdNativeVideo.VideoClickOption.FullScreen; } videoAdLoader = new NendAdNativeVideoLoader(context, mapper.spotId, mapper.apiKey, clickOption); videoAdLoader.setMediationName(MEDIATION_NAME_ADMOB); if (mediationExtras != null) { videoAdLoader.setUserId(mediationExtras.getString(NendMediationAdapter.KEY_USER_ID, "")); } }
Example #13
Source File: HomeFragment.java From Android with MIT License | 6 votes |
private void Ads(View v) { //adView = view.findViewById(R.id.adView); View adContainer = v.findViewById(R.id.adMobView); // Log.e("TAG :BANNERhomefragment",ADMOB_PLEX_BANNER_1); AdView mAdView = new AdView(mContext); mAdView.setAdSize(AdSize.SMART_BANNER); mAdView.setAdUnitId(ADMOB_PLEX_BANNER_1); ((RelativeLayout)adContainer).addView(mAdView); AdRequest adRequest = new AdRequest.Builder().build(); mAdView.loadAd(adRequest); mInterstitialAd = new InterstitialAd(getActivity()); mInterstitialAd.setAdUnitId(ADMOB_PLEX_INTERSTITIAL_1); mInterstitialAd.loadAd(new AdRequest.Builder().build()); mInterstitialAd.setAdListener(new AdListener() { @Override public void onAdClosed() { } }); }
Example #14
Source File: Action.java From admob-plus with MIT License | 6 votes |
public AdRequest buildAdRequest() { Bundle extras = new Bundle(); AdRequest.Builder builder = new AdRequest.Builder(); JSONArray testDevices = this.opts.optJSONArray("testDevices"); if (testDevices != null) { for (int i = 0; i < testDevices.length(); i++) { String testDevice = testDevices.optString(i); if (testDevice != null) { builder.addTestDevice(testDevice); } } } if (this.opts.has("childDirected")) { builder.tagForChildDirectedTreatment(opts.optBoolean("childDirected")); } if (this.opts.has("npa")) { extras.putString("npa", opts.optString("npa")); } if (this.opts.has("underAgeOfConsent")) { extras.putBoolean("tag_for_under_age_of_consent", opts.optBoolean("underAgeOfConsent")); } return builder.addNetworkExtrasBundle(AdMobAdapter.class, extras).build(); }
Example #15
Source File: AdMobPlugin.java From cordova-admob-pro with MIT License | 6 votes |
/** Gets a string error reason from an error code. */ public String getErrorReason(int errorCode) { String errorReason = ""; switch(errorCode) { case AdRequest.ERROR_CODE_INTERNAL_ERROR: errorReason = "Internal error"; break; case AdRequest.ERROR_CODE_INVALID_REQUEST: errorReason = "Invalid request"; break; case AdRequest.ERROR_CODE_NETWORK_ERROR: errorReason = "Network Error"; break; case AdRequest.ERROR_CODE_NO_FILL: errorReason = "No fill"; break; } return errorReason; }
Example #16
Source File: MainActivity.java From snippets-android with Apache License 2.0 | 6 votes |
public void executeAdsPolicy() { // [START pred_ads_policy] FirebaseRemoteConfig config = FirebaseRemoteConfig.getInstance(); String adPolicy = config.getString("ads_policy"); boolean will_not_spend = config.getBoolean("will_not_spend"); AdView mAdView = findViewById(R.id.adView); if (adPolicy.equals("ads_always") || (adPolicy.equals("ads_nonspenders") && will_not_spend)) { AdRequest adRequest = new AdRequest.Builder().build(); mAdView.loadAd(adRequest); mAdView.setVisibility(View.VISIBLE); } else { mAdView.setVisibility(View.GONE); } FirebaseAnalytics.getInstance(this).logEvent("ads_policy_set", new Bundle()); // [END pred_ads_policy] }
Example #17
Source File: MainActivity.java From funcodetuts with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); MobileAds.initialize(getApplicationContext(), "YOUR UNIT ID"); AdView adView = (AdView) this.findViewById(R.id.adMob); //request TEST ads to avoid being disabled for clicking your own ads AdRequest adRequest = new AdRequest.Builder() .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)// This is for emulators //test mode on DEVICE (this example code must be replaced with your device uniquq ID) // .addTestDevice("2EAB96D84FE62876379A9C030AA6A0AC") // Nexus 5 .build(); adView.loadAd(adRequest); }
Example #18
Source File: MainActivity.java From AndroidKeyboard with GNU General Public License v3.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); LinearLayout enableSetting = findViewById(R.id.layout_EnableSetting); LinearLayout addKeyboards = findViewById(R.id.layout_AddLanguages); LinearLayout chooseInputMethod = findViewById(R.id.layout_ChooseInput); LinearLayout chooseTheme = findViewById(R.id.layout_ChooseTheme); LinearLayout manageDictionaries = findViewById(R.id.layout_ManageDictionary); LinearLayout about = findViewById(R.id.layout_about); enableSetting.setOnClickListener(this); addKeyboards.setOnClickListener(this); chooseInputMethod.setOnClickListener(this); chooseTheme.setOnClickListener(this); manageDictionaries.setOnClickListener(this); about.setOnClickListener(this); AdView adView = this.findViewById(R.id.adView); AdRequest adRequest = new AdRequest.Builder() .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .addTestDevice("D17FE6D8441E3F2375E3709A2EED851B") .build(); adView.loadAd(adRequest); }
Example #19
Source File: SampleMediationBannerEventForwarder.java From googleads-mobile-android-mediation with Apache License 2.0 | 6 votes |
@Override public void onAdFetchFailed(SampleErrorCode errorCode) { switch (errorCode) { case UNKNOWN: mediationListener.onAdFailedToLoad(adapter, AdRequest.ERROR_CODE_INTERNAL_ERROR); break; case BAD_REQUEST: mediationListener.onAdFailedToLoad(adapter, AdRequest.ERROR_CODE_INVALID_REQUEST); break; case NETWORK_ERROR: mediationListener.onAdFailedToLoad(adapter, AdRequest.ERROR_CODE_NETWORK_ERROR); break; case NO_INVENTORY: mediationListener.onAdFailedToLoad(adapter, AdRequest.ERROR_CODE_NO_FILL); break; } }
Example #20
Source File: ListActivity.java From SmallBang with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_list); AdView mAdView = findViewById(R.id.adView); AdRequest adRequest = new AdRequest.Builder().build(); mAdView.loadAd(adRequest); for (int i = 0; i < 100; i++) { Item item = new Item(); item.content = "this is content : " + i; data.add(item); } RecyclerView recyclerView = findViewById(R.id.recyclerView); recyclerView.setLayoutManager(new LinearLayoutManager(this)); recyclerView.setAdapter(new MyAdapter()); }
Example #21
Source File: BaseAdsActivity.java From twoh-android-material-design with MIT License | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mFirebaseAnalytics = FirebaseAnalytics.getInstance(this); AdView mAdView = (AdView) findViewById(R.id.adView); AdRequest adRequest = new AdRequest.Builder().addTestDevice("22FFB74E3E00DEC909938864EE0B401E").build(); mAdView.loadAd(adRequest); System.out.println("Outer class "+this.getClass().getSimpleName()); Bundle bundle = new Bundle(); bundle.putString(FirebaseAnalytics.Param.ITEM_NAME, this.getClass().getSimpleName()); bundle.putString(FirebaseAnalytics.Param.CONTENT_TYPE, "activity"); mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.VIEW_ITEM, bundle); initInterstitial(); }
Example #22
Source File: VungleBannerAdapter.java From googleads-mobile-android-mediation with Apache License 2.0 | 6 votes |
void requestBannerAd(@NonNull Context context, @NonNull String appId) { Log.d(TAG, "requestBannerAd: " + this); mPendingRequestBanner = true; VungleInitializer.getInstance() .initialize( appId, context.getApplicationContext(), new VungleInitializer.VungleInitializationListener() { @Override public void onInitializeSuccess() { loadBanner(); } @Override public void onInitializeError(String errorMessage) { Log.d(TAG, "SDK init failed: " + VungleBannerAdapter.this); mVungleManager.removeActiveBannerAd(mPlacementId); if (mPendingRequestBanner && mVungleListener != null) { mVungleListener.onAdFailedToLoad(AdRequest.ERROR_CODE_INTERNAL_ERROR); } } }); }
Example #23
Source File: VerizonMediaBannerRenderer.java From googleads-mobile-android-mediation with Apache License 2.0 | 6 votes |
@Override public void onError(final InlineAdFactory inlineAdFactory, final ErrorInfo errorInfo) { Log.i(TAG, "Verizon Ads SDK Inline Ad request failed (" + errorInfo.getErrorCode() + "): " + errorInfo.getDescription()); final int errorCode; switch (errorInfo.getErrorCode()) { case VASAds.ERROR_AD_REQUEST_FAILED: errorCode = AdRequest.ERROR_CODE_INTERNAL_ERROR; break; case VASAds.ERROR_AD_REQUEST_TIMED_OUT: errorCode = AdRequest.ERROR_CODE_NETWORK_ERROR; break; default: errorCode = AdRequest.ERROR_CODE_NO_FILL; } ThreadUtils.postOnUiThread(new Runnable() { @Override public void run() { MediationBannerAdapter adapter = bannerAdapterWeakRef.get(); if (bannerListener != null && adapter != null) { bannerListener.onAdFailedToLoad(adapter, errorCode); } } }); }
Example #24
Source File: MainActivity.java From googleads-mobile-android-mediation with Apache License 2.0 | 6 votes |
private void requestCustomEventRewardedAd() { RewardedAdLoadCallback adLoadCallback = new RewardedAdLoadCallback() { @Override public void onRewardedAdLoaded() { customEventRewardedButton.setEnabled(true); } @Override public void onRewardedAdFailedToLoad(int errorCode) { Toast.makeText(MainActivity.this, String.format("Rewarded ad failed to load with code %d", errorCode), Toast.LENGTH_LONG).show(); customEventRewardedButton.setEnabled(true); } }; customEventRewardedAd = new RewardedAd(this, getString(R.string.customevent_rewarded_ad_unit_id)); customEventRewardedAd.loadAd(new AdRequest.Builder().build(), adLoadCallback); }
Example #25
Source File: SampleCustomInterstitialEventForwarder.java From googleads-mobile-android-mediation with Apache License 2.0 | 6 votes |
@Override public void onAdFetchFailed(SampleErrorCode errorCode) { switch (errorCode) { case UNKNOWN: interstitialListener.onAdFailedToLoad(AdRequest.ERROR_CODE_INTERNAL_ERROR); break; case BAD_REQUEST: interstitialListener.onAdFailedToLoad(AdRequest.ERROR_CODE_INVALID_REQUEST); break; case NETWORK_ERROR: interstitialListener.onAdFailedToLoad(AdRequest.ERROR_CODE_NETWORK_ERROR); break; case NO_INVENTORY: interstitialListener.onAdFailedToLoad(AdRequest.ERROR_CODE_NO_FILL); break; } }
Example #26
Source File: NativeVideoAdLoader.java From googleads-mobile-android-mediation with Apache License 2.0 | 5 votes |
@Override public void onSuccess(NendAdNativeVideo nendAdNativeVideo) { Context context = forwarder.getContextFromWeakReference(); if (context == null) { Log.e(TAG, "Your context may be released..."); forwarder.failedToLoad(AdRequest.ERROR_CODE_INVALID_REQUEST); } else { NendUnifiedNativeVideoAdMapper videoAdMapper = new NendUnifiedNativeVideoAdMapper(context, forwarder, nendAdNativeVideo); forwarder.setUnifiedNativeAdMapper(videoAdMapper); forwarder.adLoaded(); } }
Example #27
Source File: MainActivity.java From BusyBox with Apache License 2.0 | 5 votes |
private void setupBanners() { AdRequest.Builder builder = new AdRequest.Builder(); if (App.isDebuggable()) { builder.addTestDevice(DeviceUtils.getDeviceId()); } adViewTiers[currentAdViewIndex] = new AdView(this); adViewTiers[currentAdViewIndex].setAdSize(AdSize.SMART_BANNER); adViewTiers[currentAdViewIndex] .setAdUnitId(getResources().getStringArray(R.array.banners_id)[currentAdViewIndex]); adViewTiers[currentAdViewIndex].setAdListener(new AdListener() { @Override public void onAdFailedToLoad(int errorCode) { if (currentAdViewIndex != (adViewTiers.length - 1)) { currentAdViewIndex++; setupBanners(); } else if (adContainer.getVisibility() == View.VISIBLE) { Technique.SLIDE_OUT_DOWN.getComposer().hideOnFinished().playOn(adContainer); } } @Override public void onAdLoaded() { adContainer.setVisibility(View.VISIBLE); if (adContainer.getChildCount() != 0) { adContainer.removeAllViews(); } adContainer.addView(adViewTiers[currentAdViewIndex]); Analytics.newEvent("on_ad_loaded") .put("id", adViewTiers[currentAdViewIndex].getAdUnitId()).log(); } }); adViewTiers[currentAdViewIndex].loadAd(builder.build()); }
Example #28
Source File: MyActivity.java From android-ads with Apache License 2.0 | 5 votes |
private void startGame() { // Request a new ad if one isn't already loaded, hide the button, and kick off the timer. if (!interstitialAd.isLoading() && !interstitialAd.isLoaded()) { AdRequest adRequest = new AdRequest.Builder().build(); interstitialAd.loadAd(adRequest); } retryButton.setVisibility(View.INVISIBLE); resumeGame(GAME_LENGTH_MILLISECONDS); }
Example #29
Source File: Ad.java From Birdays with Apache License 2.0 | 5 votes |
/** * Loads AdMob banner into MainActivity */ public static void showBannerAd(final ViewGroup viewGroup, final AdView banner, final View view) { banner.loadAd(new AdRequest.Builder().build()); banner.setAdListener(new AdListener() { @Override public void onAdLoaded() { super.onAdLoaded(); setupContentViewPadding(viewGroup, banner.getHeight()); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { setBottomMargin(view, -(banner.getHeight() / 4)); } } }); }
Example #30
Source File: DetailActivity.java From NewsApp with GNU General Public License v3.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); binding = DataBindingUtil.setContentView(this, R.layout.activity_detail); makeUiFullscreen(); setupToolbar(); setupArticleAndListener(); newsRepository = NewsRepository.getInstance(this); getSavedState(); MobileAds.initialize(this, getString(R.string.admob_app_id)); AdRequest adRequest = new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR).build(); binding.adView.loadAd(adRequest); binding.ivSave.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (isSaved) { newsRepository.removeSaved(article.id); } else { newsRepository.save(article.id); } } }); }