Should we first call MobileAds.setRequestConfiguration or MobileAds.initialize?

1,903 views
Skip to first unread message

Yan Cheng Cheok

unread,
Sep 25, 2019, 2:58:51 PM9/25/19
to Google Mobile Ads SDK Developers

There isn't much documentation on this. I was wondering, should we first call


RequestConfiguration conf= new RequestConfiguration.Builder()
        .setMaxAdContentRating(
                MAX_AD_CONTENT_RATING_T)
        .build();

MobileAds.setRequestConfiguration(conf);
MobileAds.initialize(context, APP_ID);


Or


MobileAds.initialize(context, APP_ID);
RequestConfiguration conf= new RequestConfiguration.Builder()
        .setMaxAdContentRating(
                MAX_AD_CONTENT_RATING_T)
        .build();

MobileAds.setRequestConfiguration(conf);


In https://developers.google.com/admob/android/quick-start


Although Google recommend calling MobileAds.initialize as early as possible

Before loading ads, have your app initialize the Mobile Ads SDK by calling MobileAds.initialize() which initializes the SDK and calls back a completion listener once initialization is complete (or after a 30-second timeout). This needs to be done only once, ideally at app launch.

They also mention "request-specific flags" need to be set before MobileAds.initialize.

Warning: Ads may be preloaded by the Mobile Ads SDK or mediation partner SDKs upon calling MobileAds.initialize(). If you need to obtain consent from users in the European Economic Area (EEA), set any request-specific flags (such as tagForChildDirectedTreatment or tag_for_under_age_of_consent), or otherwise take action before loading ads, ensure you do so before initializing the Mobile Ads SDK.

So, not super clear on which should be called first.

Mobile Ads SDK Forum Advisor Prod

unread,
Sep 25, 2019, 4:40:39 PM9/25/19
to yanchen...@gmail.com, google-adm...@googlegroups.com

Hello there,

Thanks for reaching out to us. You need to set the configuration before initializing the Mobile Ads SDK. So the following would be the right step -

MobileAds.setRequestConfiguration(conf); MobileAds.initialize(context, APP_ID);

Let us know if you need anything else.

Regards,
Deepika Uragayala
Mobile Ads SDK Team



ref:_00D1U1174p._5001UHHy07:ref

Style-7

unread,
Mar 17, 2020, 2:16:18 AM3/17/20
to Google Mobile Ads SDK Developers
Hello,
Is this global filter and no more needed use Extras on the AdRequest?
So, my first step to use it for children:

RequestConfiguration requestConfiguration = MobileAds.getRequestConfiguration().toBuilder()
.setTagForChildDirectedTreatment( TAG_FOR_CHILD_DIRECTED_TREATMENT_TRUE )
//.setTagForUnderAgeOfConsent( TAG_FOR_UNDER_AGE_OF_CONSENT_TRUE )
.setMaxAdContentRating( MAX_AD_CONTENT_RATING_G )
.build();

MobileAds.setRequestConfiguration( requestConfiguration );

MobileAds.initialize( context, context.getString( R.string.app_id ) );


Second step is simple:


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

Is it right? 
Thank you.

Mobile Ads SDK Forum Advisor Prod

unread,
Mar 17, 2020, 4:46:45 AM3/17/20
to style...@mail.ru, google-adm...@googlegroups.com

Hi there,

 

Thank you for reaching out to us.

 

With regard to your concern, since you're already using the RequestConfiguration object which is applied globally via the MobileAds static method, there is no need to add additional extras on the AdRequest.

 

Regards,

Mark Albios

Mobile Ads SDK Team



ref:_00D1U1174p._5001UXVIbO:ref
Reply all
Reply to author
Forward
0 new messages