com.google.android.gms.ads.AdView Java Examples

The following examples show how to use com.google.android.gms.ads.AdView. 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: AdmobFetcherBanner.java    From admobadapter with Apache License 2.0 6 votes vote down vote up
/**
 * Fetches a new banner ad.
 */
protected synchronized void fetchAd(final AdView adView) {
    if(mFetchFailCount > MAX_FETCH_ATTEMPT)
        return;

    Context context = mContext.get();

    if (context != null) {
        Log.i(TAG, "Fetching Ad now");
        new Handler(context.getMainLooper()).post(new Runnable() {
            @Override
            public void run() {
                adView.loadAd(getAdRequest()); //Fetching the ads item
            }
        });
    } else {
        mFetchFailCount++;
        Log.i(TAG, "Context is null, not fetching Ad");
    }
}
 
Example #2
Source File: AdViewIdlingResource.java    From quickstart-android with Apache License 2.0 6 votes vote down vote up
public AdViewIdlingResource(AdView adView) {
    if (adView == null) {
        throw new IllegalArgumentException(
                "Can't initialize AdViewIdlingResource with null AdView.");
    }

    this.mAdView = adView;
    this.mAdListener = new AdListener() {
        @Override
        public void onAdFailedToLoad(int i) {
            transitionToIdle();
        }

        @Override
        public void onAdLoaded() {
            transitionToIdle();
        }
    };

    mAdView.setAdListener(mAdListener);
}
 
Example #3
Source File: MainActivityFragment.java    From ud867 with MIT License 6 votes vote down vote up
@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 #4
Source File: MainActivity.java    From Simple-Blog-App with MIT License 6 votes vote down vote up
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        AdView adView = findViewById(R.id.adView);
        AdRequest adRequest = new AdRequest.Builder().build();
        adView.loadAd(adRequest);
        firebaseInit();

        blogList();
//comment
        //2323232
        floatingActionButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(MainActivity.this, ChatActivity.class));
            }
        });
        checkUserExist();
    }
 
Example #5
Source File: MainActivity.java    From funcodetuts with Apache License 2.0 6 votes vote down vote up
@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 #6
Source File: AdmobBannerRecyclerAdapterWrapper.java    From admobadapter with Apache License 2.0 6 votes vote down vote up
/**
 * Creates N instances {@link AdView} from the next N taken instances {@link BannerAdPreset}
 * Will start async prefetch of ad blocks to use its further
 * @return last created banner AdView
 */
private AdView prefetchAds(int cntToPrefetch){
    AdView last = null;
    for (int i = 0; i < cntToPrefetch; i++) {
        final AdView item = AdViewHelper.getBannerAdView(mContext, adFetcher.takeNextAdPreset());
        adFetcher.setupAd(item);
        //50 ms throttling to prevent a high-load of server
        new Handler(mContext.getMainLooper()).postDelayed(new Runnable() {
            @Override
            public void run() {
                adFetcher.fetchAd(item);
            }
        }, 50 * i);
        last = item;
    }
    return last;
}
 
Example #7
Source File: AdmobBannerRecyclerAdapterWrapper.java    From admobadapter with Apache License 2.0 6 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) {
    if (viewHolder == null)
        return;
    if(viewHolder.getItemViewType() == getViewTypeAdBanner()) {
        BannerHolder bannerHolder = (BannerHolder) viewHolder;
        ViewGroup wrapper = bannerHolder.getAdViewWrapper();
        int adPos = AdapterCalculator.getAdIndex(position);
        AdView adView = adFetcher.getAdForIndex(adPos);
        if (adView == null)
            adView = prefetchAds(1);
        AdViewWrappingStrategy.recycleAdViewWrapper(wrapper, adView);
        //make sure the AdView for this position doesn't already have a parent of a different recycled BannerHolder.
        if (adView.getParent() != null)
            ((ViewGroup) adView.getParent()).removeView(adView);
        AdViewWrappingStrategy.addAdViewToWrapper(wrapper, adView);

    } else {
        int origPos = AdapterCalculator.getOriginalContentPosition(position,
                adFetcher.getFetchingAdsCount(), mAdapter.getItemCount());
        mAdapter.onBindViewHolder(viewHolder, origPos);
    }
}
 
Example #8
Source File: AdmobBannerRecyclerAdapterWrapper.java    From admobadapter with Apache License 2.0 6 votes vote down vote up
@Override
public void onAdFailed(int adIdx, int errorCode, Object adPayload) {
    AdView adView = (AdView) adPayload;
    if (adView != null) {
        ViewParent parent = adView.getParent();
        if(parent == null || parent instanceof RecyclerView)
            adView.setVisibility(View.GONE);
        else {
            while (parent.getParent() != null && !(parent.getParent() instanceof RecyclerView))
                parent = parent.getParent();
            ((View) parent).setVisibility(View.GONE);
        }
    }
    int pos = getAdapterCalculator().translateAdToWrapperPosition(Math.max(adIdx,0));
    notifyItemRangeChanged(pos, pos+15);
}
 
Example #9
Source File: TvShowsFragment.java    From Android with MIT License 6 votes vote down vote up
private void Ads(View v) {
    View adContainer1 = v.findViewById(R.id.adView_tvshow_fragment);

    AdView mAdView = new AdView(mContext);
    mAdView.setAdSize(AdSize.MEDIUM_RECTANGLE);
    mAdView.setAdUnitId(ADMOB_PLEX_BANNER_2);
    ((RelativeLayout)adContainer1).addView(mAdView);
    AdRequest adRequest = new AdRequest.Builder().build();
    mAdView.loadAd(adRequest);


    View adContainer2 = v.findViewById(R.id.adView_tvshow_fragment2);
    AdView mAdVie2 = new AdView(mContext);
    mAdVie2.setAdSize(AdSize.SMART_BANNER);
    mAdVie2.setAdUnitId(ADMOB_PLEX_BANNER_2);
    ((RelativeLayout)adContainer2).addView(mAdVie2);
    AdRequest adReques2 = new AdRequest.Builder().build();
    mAdVie2.loadAd(adReques2);
}
 
Example #10
Source File: HomeFragment.java    From Android with MIT License 6 votes vote down vote up
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 #11
Source File: MainActivity.java    From DualSIMCard with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    GsmCellLocation cl = (GsmCellLocation) CellLocation.getEmpty();
    CellLocation.requestLocationUpdate();
    System.out.println("GsmCellLocation " + cl.toString());
    MainActivity.context = getApplicationContext();
    setContentView(R.layout.activity_dual_sim_card_main);

    AdView mAdView = (AdView) findViewById(R.id.adView);
    AdRequest adRequest = new AdRequest.Builder().build();
    mAdView.loadAd(adRequest);


    clockwise(findViewById(R.id.listView));
    //readSims();
}
 
Example #12
Source File: AdmobFetcherBanner.java    From admobadapter with Apache License 2.0 6 votes vote down vote up
/**
 * Subscribing to the banner ads events
 * @param adView
 */
protected synchronized void setupAd(final AdView adView) {
    if(mFetchFailCount > MAX_FETCH_ATTEMPT)
        return;

    if(!mPrefetchedAds.contains(adView))
        mPrefetchedAds.add(adView);
    adView.setAdListener(new AdListener() {
        @Override
        public void onAdFailedToLoad(int errorCode) {
            super.onAdFailedToLoad(errorCode);
            // Handle the failure by logging, altering the UI, etc.
            onFailedToLoad(adView, errorCode);
        }
        @Override
        public void onAdLoaded() {
            super.onAdLoaded();
            onFetched(adView);
        }
    });
}
 
Example #13
Source File: SearchActivity.java    From aMuleRemote with GNU General Public License v3.0 6 votes vote down vote up
@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 #14
Source File: GooglePlayServicesBanner.java    From mobile-sdk-android with Apache License 2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #15
Source File: MainActivity.java    From USB_Mass_Storage_Enabler with MIT License 6 votes vote down vote up
void initADs() {

		if(enableADs) {
			//https://firebase.google.com/docs/admob/android/quick-start
			MobileAds.initialize(getApplicationContext(), getString(R.string.ad_app_id));
			AdView mAdView = (AdView) findViewById(R.id.adView);
			AdRequest adRequest = new AdRequest.Builder().build();
			mAdView.loadAd(adRequest);
			Log.d(LOG_TAG, "Ads initialized..");

			mInterstitialAd = new InterstitialAd(this);
			mInterstitialAd.setAdUnitId(getString(R.string.interstitial_ad_unit_id));
			mInterstitialAd.setAdListener(new AdListener() {
				@Override
				public void onAdClosed() {
					//requestNewInterstitial();
				}
			});

			requestNewInterstitial();
		}
	}
 
Example #16
Source File: MainActivity.java    From snippets-android with Apache License 2.0 6 votes vote down vote up
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: AdmobBannerAdapterWrapper.java    From admobadapter with Apache License 2.0 6 votes vote down vote up
/**
 * Creates N instances {@link AdView} from the next N taken instances {@link BannerAdPreset}
 * Will start async prefetch of ad blocks to use its further
 * @return last created banner AdView
 */
private AdView prefetchAds(int cntToPrefetch){
    AdView last = null;
    for (int i = 0; i < cntToPrefetch; i++){
        final AdView item = AdViewHelper.getBannerAdView(mContext, adFetcher.takeNextAdPreset());
        adFetcher.setupAd(item);
        //50 ms throttling to prevent a high-load of server
        new Handler(mContext.getMainLooper()).postDelayed(new Runnable() {
            @Override
            public void run() {
                adFetcher.fetchAd(item);
            }
        }, 50 * i);
        last = item;
    }
    return last;
}
 
Example #18
Source File: AdsUtils.java    From remixed-dungeon with GNU General Public License v3.0 6 votes vote down vote up
public static void removeTopBanner() {
    Game.instance().runOnUiThread(() -> {
        int index = bannerIndex();
        if (index >= 0) {

            View adview = Game.instance().getLayout().getChildAt(index);

            if (adview instanceof BannerView) {
                Appodeal.hide(Game.instance(), Appodeal.BANNER);
            }
            if(adview instanceof AdView) {
                ((AdView)adview).destroy();
            }

            Game.instance().getLayout().removeViewAt(index);
        }
    });
}
 
Example #19
Source File: AdmobFetcherBanner.java    From admobadapter with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized void destroyAllAds() {
    super.destroyAllAds();
    for(AdView ad:mPrefetchedAds){
        ad.destroy();
    }
    mPrefetchedAds.clear();
}
 
Example #20
Source File: BannerAdViewWrappingStrategy.java    From admobadapter with Apache License 2.0 5 votes vote down vote up
/**
 * This method can be overridden to recycle (remove) {@param ad} from {@param wrapper} view before adding to wrap.
 * By default it will look for {@param ad} in the direct children of {@param wrapper} and remove the first occurrence.
 * See the super's implementation for instance.
 * The NativeExpressHolder recycled by the RecyclerView may be a different
 * instance than the one used previously for this position. Clear the
 * wrapper of any subviews in case it has a different
 * AdView associated with it
 */
@Override
protected void recycleAdViewWrapper(@NonNull ViewGroup wrapper, @NonNull AdView ad) {
    for (int i = 0; i < wrapper.getChildCount(); i++) {
        View v = wrapper.getChildAt(i);
        if (v instanceof AdView) {
            wrapper.removeViewAt(i);
            break;
        }
    }
}
 
Example #21
Source File: AdmobFetcherBanner.java    From admobadapter with Apache License 2.0 5 votes vote down vote up
/**
 * A handler for failed banner ads
 * @param adView
 */
private synchronized void onFailedToLoad(AdView adView, int errorCode) {
    Log.i(TAG, "onAdFailedToLoad " + errorCode);
    mFetchFailCount++;
    mNoOfFetchedAds = Math.max(mNoOfFetchedAds - 1, 0);
    //Since Fetch Ad is only called once without retries
    //hide ad row / rollback its count if still not added to list
    mPrefetchedAds.remove(adView);
    onAdFailed(mNoOfFetchedAds - 1, errorCode, adView);
}
 
Example #22
Source File: MainActivity.java    From GooglePlayServiceLocationSupport with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mOldLocation = (TextView) findViewById(R.id.oldlocation);
    mNewLocation = (TextView) findViewById(R.id.newlocation);
    AdView mAdView = (AdView) findViewById(R.id.adView);

    mInterstitialAd = new InterstitialAd(this);
    mInterstitialAd.setAdUnitId(getResources().getString(R.string.interstitial_ad));
    mInterstitialAd.setAdListener(new AdListener() {
        @Override
        public void onAdClosed() {
            startActivity(new Intent(MainActivity.this, FragmentLocationActivity.class));
        }
    });
    AdRequest adRequest = new AdRequest.Builder().build();
    mInterstitialAd.loadAd(adRequest);

    adRequest = new AdRequest.Builder().build();
    mAdView.loadAd(adRequest);
    findViewById(R.id.btn_fragment).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mInterstitialAd != null && mInterstitialAd.isLoaded())
                mInterstitialAd.show();
            else startActivity(new Intent(MainActivity.this, FragmentLocationActivity.class));
        }
    });
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
}
 
Example #23
Source File: MoticonAdapter.java    From Moticons with GNU General Public License v3.0 5 votes vote down vote up
public MoticonViewHolder(View v) {
    super(v);
    vMoticonName = (TextView) v.findViewById(R.id.moticon_name);
    vMoticonTimes = (TextView) v.findViewById(R.id.moticon_times);
    vMoticonCategory = (TextView) v.findViewById(R.id.moticon_category);
    vMoticonCard = (CardView) v.findViewById(R.id.card_moticon);
    vAdCard = (CardView) v.findViewById(R.id.card_ad);
    vAd = (AdView) v.findViewById(R.id.adView);
    vAdRemove = (TextView) v.findViewById(R.id.ad_remove);
}
 
Example #24
Source File: Ad.java    From Birdays with Apache License 2.0 5 votes vote down vote up
/**
 * 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 #25
Source File: ChangeBrightness.java    From NightSight with Apache License 2.0 5 votes vote down vote up
void initialize() {

        parent = (RelativeLayout) findViewById(R.id.parent);
        adView = (AdView) findViewById(R.id.adView);
        AdRequest adRequest = new AdRequest.Builder()
                .build();
        adView.loadAd(adRequest);

        EventBus.getDefault().register(new Darkness());
        recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
        colorAdapter = new ColorAdapter(this);
        colorAdapter.setColorData(getMockData());
        StaggeredGridLayoutManager staggeredGridLayoutManager = new StaggeredGridLayoutManager(4, StaggeredGridLayoutManager.VERTICAL);
        recyclerView.setLayoutManager(staggeredGridLayoutManager);
        //    GridLayoutManager gridLayoutManager = new GridLayoutManager(getApplicationContext(), 3);
        //   recyclerView.setLayoutManager(gridLayoutManager);
        //   recyclerView.setHasFixedSize(true);
        recyclerView.setAdapter(colorAdapter);

        sharedPrefs = new SharedPrefs(this);
        seekBar = (SeekBar) findViewById(R.id.seekBar1);
        startStop = (Button) findViewById(R.id.startStop);
        seekValue = (TextView) findViewById(R.id.seekPercentage);
        seekValue.setText("( Brightness " + sharedPrefs.getBrightness() / 2 + "% )");

        seekBar.setMax(200);
        seekBar.setProgress(sharedPrefs.getBrightness());

        if (sharedPrefs.isService()) {
            startStop.setText("Stop");

        } else {
            startStop.setText("Start");
        }


    }
 
Example #26
Source File: AdvancedOptions.java    From USB_Mass_Storage_Enabler with MIT License 5 votes vote down vote up
void initADs() {

		if(MainActivity.enableADs) {
		/*AdView mAdView = (AdView) findViewById(R.id.adViewInSettings);
		mAdView.loadAd(new AdRequest.Builder().build());*/

			AdView mAdView1 = (AdView) findViewById(R.id.adViewInSettingsBottom);
			mAdView1.loadAd(new AdRequest.Builder().build());
			Log.d(LOG_TAG, "Ads initialized in Settings Activity..");
		}
	}
 
Example #27
Source File: MainActivity.java    From BusyBox with Apache License 2.0 5 votes vote down vote up
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: MainActivity.java    From BusyBox with Apache License 2.0 5 votes vote down vote up
@Override
public void onDestroy() {
    super.onDestroy();
    EventBus.getDefault().unregister(this);
    if (bp != null) {
        bp.release();
    }
    if (!Monetize.isAdsRemoved()) {
        for (AdView adView : adViewTiers) {
            if (adView != null) {
                adView.destroy();
            }
        }
    }
}
 
Example #29
Source File: MainActivity.java    From BusyBox with Apache License 2.0 5 votes vote down vote up
@Override
protected void onResume() {
    super.onResume();
    if (!Monetize.isAdsRemoved()) {
        for (AdView adView : adViewTiers) {
            if (adView != null) {
                adView.resume();
            }
        }
    }
}
 
Example #30
Source File: MainActivity.java    From googleads-mobile-android-examples with Apache License 2.0 5 votes vote down vote up
@Override
protected void onResume() {
    for (Object item : recyclerViewItems) {
        if (item instanceof AdView) {
            AdView adView = (AdView) item;
            adView.resume();
        }
    }
    super.onResume();
}