diff --git a/umpexample/app/src/main/java/com/google/ads/interactivemedia/v3/samples/umpimaapp/ConsentManager.java b/umpexample/app/src/main/java/com/google/ads/interactivemedia/v3/samples/umpimaapp/ConsentManager.java index 8e2b412..577f5f8 100644 --- a/umpexample/app/src/main/java/com/google/ads/interactivemedia/v3/samples/umpimaapp/ConsentManager.java +++ b/umpexample/app/src/main/java/com/google/ads/interactivemedia/v3/samples/umpimaapp/ConsentManager.java @@ -37,8 +37,8 @@ public boolean canRequestAds() { } // [START is_privacy_options_required] - /** Helper function to determine if GDPR consent messages are required. */ - public boolean areGDPRConsentMessagesRequired() { + /** Helper function to determine if a privacy options entry point is required. */ + public boolean isPrivacyOptionsRequired() { return consentInformation.getPrivacyOptionsRequirementStatus() == PrivacyOptionsRequirementStatus.REQUIRED; } diff --git a/umpexample/app/src/main/java/com/google/ads/interactivemedia/v3/samples/umpimaapp/MyActivity.java b/umpexample/app/src/main/java/com/google/ads/interactivemedia/v3/samples/umpimaapp/MyActivity.java index ff8511e..1b658f4 100644 --- a/umpexample/app/src/main/java/com/google/ads/interactivemedia/v3/samples/umpimaapp/MyActivity.java +++ b/umpexample/app/src/main/java/com/google/ads/interactivemedia/v3/samples/umpimaapp/MyActivity.java @@ -105,12 +105,17 @@ protected void onCreate(Bundle savedInstanceState) { // [START add_privacy_options] // Check ConsentInformation.getPrivacyOptionsRequirementStatus() to see the button should // be shown or hidden. - if (consentManager.areGDPRConsentMessagesRequired()) { + if (consentManager.isPrivacyOptionsRequired()) { privacyButton.setVisibility(View.VISIBLE); } // [END add_privacy_options] // [END_EXCLUDE] }); + + // This sample attempts to load ads using consent obtained in the previous session. + if (consentManager.canRequestAds()) { + initializeImaSdk(); + } // [END can_request_ads] privacyButton.setOnClickListener( @@ -126,6 +131,11 @@ protected void onCreate(Bundle savedInstanceState) { // [START request_ads] private void initializeImaSdk() { + if (sdkFactory != null) { + // If the SDK is already initialized, do nothing. + return; + } + sdkFactory = ImaSdkFactory.getInstance(); adDisplayContainer =