Skip to content

Commit

Permalink
Updates the UMP example app to better handle latency.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 688257795
  • Loading branch information
google-ima-devrel-bot authored and IMA Developer Relations committed Oct 22, 2024
1 parent 4263693 commit 099ca02
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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 =
Expand Down

0 comments on commit 099ca02

Please sign in to comment.