Class AdConfig

java.lang.Object
com.codename1.ads.AdConfig

public class AdConfig extends java.lang.Object
Configuration passed once to AdManager.initialize(AdConfig, AdCallback). Controls test mode and the global compliance flags every modern ad network requires (child directed treatment, under-age-of-consent treatment and a maximum ad content rating).
  • Field Details

    • TAG_UNSPECIFIED

      public static final int TAG_UNSPECIFIED
      Unspecified child directed treatment (let the network decide).
      See Also:
    • TAG_TRUE

      public static final int TAG_TRUE
      Tag requests as directed to children (COPPA).
      See Also:
    • TAG_FALSE

      public static final int TAG_FALSE
      Tag requests as not directed to children.
      See Also:
    • RATING_G

      public static final int RATING_G
      Content rating: general audiences.
      See Also:
    • RATING_PG

      public static final int RATING_PG
      Content rating: parental guidance.
      See Also:
    • RATING_T

      public static final int RATING_T
      Content rating: teen.
      See Also:
    • RATING_MA

      public static final int RATING_MA
      Content rating: mature audiences.
      See Also:
    • RATING_UNSPECIFIED

      public static final int RATING_UNSPECIFIED
      Content rating: unspecified (network default).
      See Also:
  • Constructor Details

    • AdConfig

      public AdConfig()
  • Method Details

    • isTestMode

      public boolean isTestMode()
      When true the provider serves test ads on every device (in addition to any explicit getTestDeviceIds()). Never ship a release build with test mode on or you will violate the ad network's program policies, and never click live ads during development.
    • testMode

      public AdConfig testMode(boolean testMode)
      Enables or disables global test mode.
    • addTestDevice

      public AdConfig addTestDevice(String deviceId)
      Registers a device hash that should always receive test ads. The hash is printed to the device log by the underlying SDK the first time an ad loads.
    • getTestDeviceIds

      public List<String> getTestDeviceIds()
      The registered test device hashes, never null.
    • getTestDeviceIdString

      public String getTestDeviceIdString()
      The test device hashes as a comma separated string for native bridges.
    • getTagForChildDirectedTreatment

      public int getTagForChildDirectedTreatment()
      Child directed treatment flag, one of TAG_UNSPECIFIED, TAG_TRUE, TAG_FALSE.
    • tagForChildDirectedTreatment

      public AdConfig tagForChildDirectedTreatment(int tag)
      Sets the child directed treatment flag (COPPA).
    • getTagForUnderAgeOfConsent

      public int getTagForUnderAgeOfConsent()
      Under age of consent flag, one of TAG_UNSPECIFIED, TAG_TRUE, TAG_FALSE.
    • tagForUnderAgeOfConsent

      public AdConfig tagForUnderAgeOfConsent(int tag)
      Sets the under-age-of-consent flag, used by AdConsent when gathering GDPR consent.
    • getMaxAdContentRating

      public int getMaxAdContentRating()
      The maximum ad content rating, one of the RATING_* constants.
    • maxAdContentRating

      public AdConfig maxAdContentRating(int rating)
      Caps the content rating of served ads.