com.google.ads.consent.ConsentStatus Java Examples

The following examples show how to use com.google.ads.consent.ConsentStatus. 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: ConsentManager.java    From UpdogFarmer with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Request user consent status
 */
public void requestConsentInfo() {
    final String[] publisherIds = {"pub-6413501894389361"};
    consentInfo.requestConsentInfoUpdate(publisherIds, new ConsentInfoUpdateListener() {
        @Override
        public void onConsentInfoUpdated(ConsentStatus consentStatus) {
            // User's consent status successfully updated.
            handleConsent(consentStatus);
        }

        @Override
        public void onFailedToUpdateConsentInfo(String reason) {
            Log.i(TAG, "Consent status failed to update. Reason: " + reason);
        }
    });
}
 
Example #3
Source File: ConsentManager.java    From UpdogFarmer with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Handle consent status
 */
private void handleConsent(ConsentStatus consentStatus) {
    switch (consentStatus) {
        case PERSONALIZED:
        case NON_PERSONALIZED:
            // Got user consent
            listener.onConsentInfoUpdated(consentStatus, false);
            break;
        case UNKNOWN:
            if (consentInfo.isRequestLocationInEeaOrUnknown()) {
                // EU user detected. Request user consent
                consentForm.load();
            } else {
                // Show personalized ads
                listener.onConsentInfoUpdated(consentStatus, false);
            }
            break;
    }
}
 
Example #4
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 #5
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 #6
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 #7
Source File: MainActivity.java    From UpdogFarmer with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onConsentInfoUpdated(ConsentStatus consentStatus, boolean userPrefersAdFree) {
    if (userPrefersAdFree) {
        billingManager.launchPurchaseFlow();
    } else {
        final Bundle args = new Bundle();
        if (consentStatus == ConsentStatus.NON_PERSONALIZED) {
            args.putString("npa", "1");
        }
        loadAds(args);
    }

}
 
Example #8
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 #9
Source File: ConsentManager.java    From UpdogFarmer with GNU General Public License v3.0 4 votes vote down vote up
public void revokeConsent() {
    consentInfo.setConsentStatus(ConsentStatus.UNKNOWN);
    requestConsentInfo();
}
 
Example #10
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 #11
Source File: ConsentListener.java    From UpdogFarmer with GNU General Public License v3.0 votes vote down vote up
void onConsentInfoUpdated(ConsentStatus consentStatus, boolean userPrefersAdFree);