# Class AdConfig

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

public class AdConfig extends 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 Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final int`
  `RATING_G`
  Content rating: general audiences.
  `static final int`
  `RATING_MA`
  Content rating: mature audiences.
  `static final int`
  `RATING_PG`
  Content rating: parental guidance.
  `static final int`
  `RATING_T`
  Content rating: teen.
  `static final int`
  `RATING_UNSPECIFIED`
  Content rating: unspecified (network default).
  `static final int`
  `TAG_FALSE`
  Tag requests as not directed to children.
  `static final int`
  `TAG_TRUE`
  Tag requests as directed to children (COPPA).
  `static final int`
  `TAG_UNSPECIFIED`
  Unspecified child directed treatment (let the network decide).

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `AdConfig()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `AdConfig`
  `addTestDevice(String deviceId)`
  Registers a device hash that should always receive test ads.
  `int`
  `getMaxAdContentRating()`
  The maximum ad content rating, one of the `RATING_*` constants.
  `int`
  `getTagForChildDirectedTreatment()`
  Child directed treatment flag, one of `TAG_UNSPECIFIED`, `TAG_TRUE`, `TAG_FALSE`.
  `int`
  `getTagForUnderAgeOfConsent()`
  Under age of consent flag, one of `TAG_UNSPECIFIED`, `TAG_TRUE`, `TAG_FALSE`.
  `List<String>`
  `getTestDeviceIds()`
  The registered test device hashes, never null.
  `String`
  `getTestDeviceIdString()`
  The test device hashes as a comma separated string for native bridges.
  `boolean`
  `isTestMode()`
  When true the provider serves test ads on every device (in addition to any explicit `getTestDeviceIds()`).
  `AdConfig`
  `maxAdContentRating(int rating)`
  Caps the content rating of served ads.
  `AdConfig`
  `tagForChildDirectedTreatment(int tag)`
  Sets the child directed treatment flag (COPPA).
  `AdConfig`
  `tagForUnderAgeOfConsent(int tag)`
  Sets the under-age-of-consent flag, used by `AdConsent` when gathering GDPR consent.
  `AdConfig`
  `testMode(boolean testMode)`
  Enables or disables global test mode.

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### TAG_UNSPECIFIED

    public static final int TAG_UNSPECIFIED
    Unspecified child directed treatment (let the network decide).
    See Also:
      - Constant Field Values

  - ### TAG_TRUE

    public static final int TAG_TRUE
    Tag requests as directed to children (COPPA).
    See Also:
      - Constant Field Values

  - ### TAG_FALSE

    public static final int TAG_FALSE
    Tag requests as not directed to children.
    See Also:
      - Constant Field Values

  - ### RATING_G

    public static final int RATING_G
    Content rating: general audiences.
    See Also:
      - Constant Field Values

  - ### RATING_PG

    public static final int RATING_PG
    Content rating: parental guidance.
    See Also:
      - Constant Field Values

  - ### RATING_T

    public static final int RATING_T
    Content rating: teen.
    See Also:
      - Constant Field Values

  - ### RATING_MA

    public static final int RATING_MA
    Content rating: mature audiences.
    See Also:
      - Constant Field Values

  - ### RATING_UNSPECIFIED

    public static final int RATING_UNSPECIFIED
    Content rating: unspecified (network default).
    See Also:
      - Constant Field Values

- ## 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.