Skip to content

Commit 43ce667

Browse files
google-ima-devrel-botIMA Developer Relations
authored andcommitted
Updates the UMP example app to better handle latency.
PiperOrigin-RevId: 688671005
1 parent 4263693 commit 43ce667

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

umpexample/app/src/main/java/com/google/ads/interactivemedia/v3/samples/umpimaapp/ConsentManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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
}

umpexample/app/src/main/java/com/google/ads/interactivemedia/v3/samples/umpimaapp/MyActivity.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff 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 =

0 commit comments

Comments
 (0)