File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed
umpexample/app/src/main/java/com/google/ads/interactivemedia/v3/samples/umpimaapp Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -37,8 +37,8 @@ public boolean canRequestAds() {
3737 }
3838
3939 // [START is_privacy_options_required]
40- /** Helper function to determine if GDPR consent messages are required. */
41- public boolean areGDPRConsentMessagesRequired () {
40+ /** Helper function to determine if a privacy options entry point is required. */
41+ public boolean isPrivacyOptionsRequired () {
4242 return consentInformation .getPrivacyOptionsRequirementStatus ()
4343 == PrivacyOptionsRequirementStatus .REQUIRED ;
4444 }
Original file line number Diff line number Diff line change @@ -105,12 +105,17 @@ protected void onCreate(Bundle savedInstanceState) {
105105 // [START add_privacy_options]
106106 // Check ConsentInformation.getPrivacyOptionsRequirementStatus() to see the button should
107107 // be shown or hidden.
108- if (consentManager .areGDPRConsentMessagesRequired ()) {
108+ if (consentManager .isPrivacyOptionsRequired ()) {
109109 privacyButton .setVisibility (View .VISIBLE );
110110 }
111111 // [END add_privacy_options]
112112 // [END_EXCLUDE]
113113 });
114+
115+ // This sample attempts to load ads using consent obtained in the previous session.
116+ if (consentManager .canRequestAds ()) {
117+ initializeImaSdk ();
118+ }
114119 // [END can_request_ads]
115120
116121 privacyButton .setOnClickListener (
@@ -126,6 +131,11 @@ protected void onCreate(Bundle savedInstanceState) {
126131
127132 // [START request_ads]
128133 private void initializeImaSdk () {
134+ if (sdkFactory != null ) {
135+ // If the SDK is already initialized, do nothing.
136+ return ;
137+ }
138+
129139 sdkFactory = ImaSdkFactory .getInstance ();
130140
131141 adDisplayContainer =
You can’t perform that action at this time.
0 commit comments