首页 > 解决方案 > 我无法在 java gpdr 协议上加载表单

问题描述

也许您知道有必要在 android https://developers.google.com/mobile-ads-sdk/docs/dfp/android/eu-consent中添加此协议表格

onCreate我在方法的上方添加了这段代码main_activity.java

ConsentInformation consentInformation = ConsentInformation.getInstance(this);
        String[] publisherIds = {"pub-123"};
        ConsentInformation.getInstance(this)
                .setConsentStatus(ConsentStatus.PERSONALIZED);
        ConsentInformation.getInstance(this).
                setDebugGeography(DebugGeography.DEBUG_GEOGRAPHY_EEA);
        handler = new Handler();
        consentInformation.requestConsentInfoUpdate(publisherIds, new ConsentInfoUpdateListener() {

            @Override
            public void onConsentInfoUpdated(ConsentStatus consentStatus) {
                // User's consent status successfully updated.
            }

            @Override
            public void onFailedToUpdateConsentInfo(String errorDescription) {
                // User's consent status failed to update.
            }

        });
        URL privacyUrl = null;
        try {
            // TODO: Replace with your app's privacy policy URL.
            privacyUrl = new URL("https://www.123.com/privacy");
        } catch (MalformedURLException e) {
            e.printStackTrace();
            // Handle error.
        }

        ConsentForm form = new ConsentForm.Builder(this, privacyUrl)
                .withListener(new ConsentFormListener() {
                    @Override
                    public void onConsentFormLoaded() {
                        // Consent form loaded successfully.

                    }

                    @Override
                    public void onConsentFormOpened() {
                        // Consent form was displayed.
                    }

                    @Override
                    public void onConsentFormClosed(
                            ConsentStatus consentStatus, Boolean userPrefersAdFree) {
                        // Consent form was closed.
                    }

                    @Override
                    public void onConsentFormError(String errorDescription) {
                        // Consent form error.
                    }
                })
                .withPersonalizedAdsOption()
                .withNonPersonalizedAdsOption()
                .withAdFreeOption()
                .build();
        form.load();
        form.show();

但是当我打开应用程序进行测试时,表单不会加载。问题可能出在哪里。我假设,这条线: DEBUG_GEOGRAPHY_EEA<<定义手机的位置,但我什么也没看到

谢谢你的时间 !

标签: javaandroid

解决方案


推荐阅读