简体   繁体   中英

When is an AdMob Ad Request made?

In the below code snippet, when might the Ad Request be actually made? While building the AdRequest or in loadAd?

        MobileAds.initialize(this,
            "ca-app-pub-3940256099942544~XXXXX");

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

AdRequest is just an object with fields just a structure withe all the parameters for the request and when you build it does nothing else rather than initialize those fields.

When you call the loadAd() of your AdView object is when that request is sent to admob and it will prepare your adv according to those parameters and their secrets.

This is not mentioned in the documentation of Admob integration of Banners, but yes in the Firebase integration of C++, but again not documented in the Android integration of firebase.

Here's the AdRequest struct used by a BannerView and InterstitialAd to make an ad request:

struct AdRequest {
  const char **test_device_ids;
  unsigned int test_device_id_count;
  const char **keywords;
  unsigned int keyword_count;
  const KeyValuePair *extras;
  unsigned int extras_count;
  int birthday_day;
  int birthday_month;
  int birthday_year;
  Gender gender;
  ChildDirectedTreatmentState tagged_for_child_directed_treatment;
};

Pass the AdRequest struct to the BannerView::LoadAd() and Interstitial::LoadAd() methods:

banner_view->LoadAd(my_ad_request);
interstitial_ad->LoadAd(my_ad_request);

Note: A single `AdRequest` struct can be reused for multiple calls.

Google Developer Documents suggest: An AdRequest contains targeting information used to fetch an ad. Ad requests are created using AdRequest.Builder.

So physically the AD Request is sent before loadAd() is called.

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