简体   繁体   中英

How to check if adview currently has ad running?

I currently have an adView that is launched whenever an activity is launched. I'd like to check if that adView already has an Ad running and if it does then it continues running that Ad , however, if it does not have an Ad running then I would like to load and Ad intho that adView .

This is the code currently:

private AdView mAdView;

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

this method return the status of ad whether it is showing to user or not you can use this. method in if else structure

if(!adView.isShown())
{
AdRequest adRequest = new AdRequest.Builder().build();
    mAdView.loadAd(adRequest);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM