java - 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);

1 Answer

  1. Jacob- Reply

    2019-11-13

        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);
    }
    

Leave a Reply

Your email address will not be published. Required fields are marked *

You can use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>