SDKsAndroid

Reference

Init options, theme properties, slot sizing, and ad lifecycle events for the Koah Android SDK.

Init options

Set these in the Koah(context) { … } initializer block.

ParameterTypeDefaultDescription
publisherIdString— (required)Your publisher ID from the dashboard. Must be non-blank — a blank id throws on first init.
logLevelKoahLogLevelNONENONE, ERROR, WARNING, INFO, or DEBUG — see Debugging.
baseUrlStringProductionLeave unset to use production.

Theme properties

Set these on a KoahTheme passed to ProvideKoahTheme.

ParameterTypeDefaultDescription
colorSchemeKoahColorSchemeAUTOLIGHT, DARK, or AUTO (follows the device via isSystemInDarkTheme())
accentColorColor?#0D0D0DAccent for CTA buttons and accents. Text-on-accent is computed automatically for contrast — never expose it.
fontFamilyFontFamily?null (inherits from app)Font family applied to all ad text
cornerRadiusDp19.dpCard corner radius

Slot sizing

KoahCard / KoahAd take optional width and height parameters, each a KoahAxisSize — see Sizing for the model.

ValueMeaning
null (default)Unbounded — wraps content within the parent's own bounds, keeping the most formats in play
KoahAxisSize.range(min, max)Wraps content within the dp band. At least one bound is required — range() throws; an unbounded axis is null
KoahAxisSize.fixed(dp)Exactly this many dp
KoahAxisSize.fill()Fills the parent along this axis. Requires a parent that bounds it — throws at first layout on a scroll axis

Event handling

The onEvent callback notifies you of ad lifecycle events (served, impression, viewed, click, no-fill). See How Koah works for what each event means and when it fires.

import com.koahlabs.android.KoahEvent

KoahCard(
    adContext = KoahAdContext.Conversation(question = q, answer = a),
    cacheKey = messageId,
    onEvent = { event ->
        when (event) {
            is KoahEvent.NoAdFill -> { /* no inventory */ }
            is KoahEvent.AdServed -> { /* ad delivered */ }
            is KoahEvent.ImpressionTracked -> { /* impression tracked */ }
            is KoahEvent.AdViewed -> { /* ad visible for sufficient time */ }
            is KoahEvent.AdClicked -> { /* user tapped */ }
            is KoahEvent.SlotTooSmall -> { /* slot bounds exclude the served ad */ }
            is KoahEvent.InAppBrowserClosed -> { /* in-app browser closed, app resumed */ }
            else -> {}
        }
    },
)

Age range buckets

Available KoahAgeRange buckets for visitor attributes:

UNDER_13<13
AGE_13_TO_1513–15
AGE_16_TO_1716–17
AGE_18_TO_2018–20
AGE_21_TO_2421–24
AGE_25_TO_2925–29
AGE_30_TO_3430–34
AGE_35_TO_3935–39
AGE_40_TO_4440–44
AGE_45_TO_4945–49
AGE_50_TO_5450–54
AGE_55_TO_5955–59
AGE_60_TO_6460–64
AGE_65_TO_6965–69
AGE_70_TO_7470–74
AGE_75_PLUS75+

UNDER_13 remains in the enum for source compatibility, but setAge / setAgeRange ignore any under-13 value with a warning, and a previously stored under-13 value is discarded — see Children's privacy.

Gender values

Available KoahGender values for visitor attributes: MALE, FEMALE, and UNKNOWN (clears the stored value).

Income brackets

Available KoahIncomeBracket values for visitor attributes — annual household income in USD:

ValueRange
UNDER_50KUnder $50,000
INCOME_50K_TO_100K$50,000 – $100,000
INCOME_100K_TO_150K$100,000 – $150,000
INCOME_150K_TO_200K$150,000 – $200,000
INCOME_200K_PLUS$200,000 and above
UNKNOWNClears the stored value
Was this helpful?