com.google.ads.consent.ConsentInformation Java Examples

The following examples show how to use com.google.ads.consent.ConsentInformation. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConsentSDK.java    From GDPR-Admob-Android with MIT License 6 votes vote down vote up
private void initConsentInformation(final ConsentInformationCallback callback) {
    final ConsentInformation consentInformation = ConsentInformation.getInstance(context);
    if(DEBUG) {
        if(!DEVICE_ID.isEmpty()) {
            consentInformation.addTestDevice(DEVICE_ID);
        }
        consentInformation.setDebugGeography(DebugGeography.DEBUG_GEOGRAPHY_EEA);
    }
    String[] publisherIds = {publisherId};
    consentInformation.requestConsentInfoUpdate(publisherIds, new ConsentInfoUpdateListener() {
        @Override
        public void onConsentInfoUpdated(ConsentStatus consentStatus) {
            if(callback != null) {
                callback.onResult(consentInformation, consentStatus);
            }
        }

        @Override
        public void onFailedToUpdateConsentInfo(String reason) {
            callback.onFailed(consentInformation, reason);
        }
    });
}
 
Example #2
Source File: EuConsent.java    From remixed-dungeon with GNU General Public License v3.0 6 votes vote down vote up
static public void check(final Context context) {
    if (getConsentLevel() < NON_PERSONALIZED) {

        final ConsentInformation consentInformation = ConsentInformation.getInstance(context);


        String[] publisherIds = {Game.getVar(R.string.admob_publisher_id)};
        consentInformation.requestConsentInfoUpdate(publisherIds, new ConsentInfoUpdateListener() {
            @Override
            public void onConsentInfoUpdated(ConsentStatus consentStatus) {
                if (!ConsentInformation.getInstance(context).isRequestLocationInEeaOrUnknown()) {
                    setConsentLevel(PERSONALIZED);
                }
            }

            @Override
            public void onFailedToUpdateConsentInfo(String errorDescription) {
                EventCollector.logException(errorDescription);
            }
        });
    }
}
 
Example #3
Source File: ConsentManager.java    From callmeter with GNU General Public License v3.0 6 votes vote down vote up
public void updateConsent() {
    if (!DonationHelper.hideAds(mActivity)) {
        ConsentInformation consentInformation = ConsentInformation.getInstance(mActivity);
        String[] publisherIds = {ADMOB_PUBLISHER_ID};
        consentInformation.requestConsentInfoUpdate(publisherIds, new ConsentInfoUpdateListener() {
            @Override
            public void onConsentInfoUpdated(final ConsentStatus consentStatus) {
                Log.i(TAG, "updated consent status: ", consentStatus.toString());
                checkConsentForAds();
            }

            @Override
            public void onFailedToUpdateConsentInfo(final String errorDescription) {
                Log.e(TAG, "failed to update consent info: ", errorDescription);
            }
        });
    }
}
 
Example #4
Source File: ConsentManager.java    From callmeter with GNU General Public License v3.0 6 votes vote down vote up
private boolean checkConsentForAds() {
    final ConsentInformation consentInformation = ConsentInformation.getInstance(mActivity);
    if (!consentInformation.isRequestLocationInEeaOrUnknown()) {
        Log.d(TAG, "User is outside EEA");
        return true;
    }

    final ConsentStatus consentStatus = consentInformation.getConsentStatus();
    Log.d(TAG, "ConstentStatus: ", consentStatus);

    if (ConsentStatus.UNKNOWN.equals(consentStatus)) {
        Log.d(TAG, "Need to ask for consent");
        // we need to ask for consent
        askForConsent();
        return false;
    }

    return true;
}
 
Example #5
Source File: EuConsent.java    From remixed-dungeon with GNU General Public License v3.0 5 votes vote down vote up
static public void setConsentLevel(int level) {

        switch (level){
            case NON_PERSONALIZED:
                ConsentInformation.getInstance(Game.instance())
                        .setConsentStatus(ConsentStatus.NON_PERSONALIZED);
            break;
            case PERSONALIZED:
                ConsentInformation.getInstance(Game.instance())
                        .setConsentStatus(ConsentStatus.PERSONALIZED);
            break;
        }

        Preferences.INSTANCE.put(Preferences.KEY_EU_CONSENT_LEVEL, level);
    }
 
Example #6
Source File: ConsentManager.java    From callmeter with GNU General Public License v3.0 5 votes vote down vote up
public boolean needConsent() {
    final ConsentInformation consentInformation = ConsentInformation.getInstance(mActivity);
    if (!consentInformation.isRequestLocationInEeaOrUnknown()) {
        Log.d(TAG, "User is outside EEA");
        return false;
    } else {
        return true;
    }
}
 
Example #7
Source File: ConsentManager.java    From UpdogFarmer with GNU General Public License v3.0 4 votes vote down vote up
private void setupConsentInfo() {
    consentInfo = ConsentInformation.getInstance(context.getApplicationContext());
}
 
Example #8
Source File: ConsentSDK.java    From GDPR-Admob-Android with MIT License votes vote down vote up
abstract public void onResult(ConsentInformation consentInformation, ConsentStatus consentStatus); 
Example #9
Source File: ConsentSDK.java    From GDPR-Admob-Android with MIT License votes vote down vote up
abstract public void onFailed(ConsentInformation consentInformation, String reason);