This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Bundle extras = new Bundle(); | |
extras.putString("npa", "1"); | |
AdRequest request = new AdRequest.Builder() | |
.addNetworkExtrasBundle(AdMobAdapter.class, extras) | |
.build(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private boolean hasAttribute(String input, int index) { | |
if (input == null) return false; | |
return input.length() >= index && input.charAt(index-1) == '1'; | |
} | |
private boolean hasConsentFor(List<Integer> indexes, String purposeConsent, boolean hasVendorConsent) { | |
for (Integer p: indexes) { | |
if (!hasAttribute(purposeConsent, p)) { | |
Log.e(TAG, "hasConsentFor: denied for purpose #" + p ); | |
return false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public boolean canShowPersonalizedAds(Context context){ | |
prefs = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext()); | |
String purposeConsent = prefs.getString("IABTCF_PurposeConsents", ""); | |
String vendorConsent = prefs.getString("IABTCF_VendorConsents",""); | |
String vendorLI = prefs.getString("IABTCF_VendorLegitimateInterests",""); | |
String purposeLI = prefs.getString("IABTCF_PurposeLegitimateInterests",""); | |
int googleId = 755; | |
boolean hasGoogleVendorConsent = hasAttribute(vendorConsent, googleId); | |
boolean hasGoogleVendorLI = hasAttribute(vendorLI, googleId); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public boolean canShowAds(Context context){ | |
prefs = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext()); | |
String purposeConsent = prefs.getString("IABTCF_PurposeConsents", ""); | |
String vendorConsent = prefs.getString("IABTCF_VendorConsents",""); | |
String vendorLI = prefs.getString("IABTCF_VendorLegitimateInterests",""); | |
String purposeLI = prefs.getString("IABTCF_PurposeLegitimateInterests",""); | |
int googleId = 755; | |
boolean hasGoogleVendorConsent = hasAttribute(vendorConsent, googleId); | |
boolean hasGoogleVendorLI = hasAttribute(vendorLI, googleId); |