Android

Overview

The Android SDK is documented around listener-based integration. For consuming app developers, the primary classes are TrustArc and TASharedInstance, with TrustArcVendorConsentViewModel available as an optional ViewModel helper.

  • TrustArc — Primary interface for SDK initialization, consent UI handling, listener registration, and consent retrieval.
  • TASharedInstance — Singleton manager that stores and returns the active TrustArc instance.
  • TrustArcVendorConsentViewModel — Legacy ViewModel wrapper around stored vendor consent data; keep only as a backward-compatible reference.
TrustArc Class
Constructors
Constructor Description
TrustArc(context: Context, sdkMode: SdkMode = Standard) Creates a new TrustArc instance with the selected SDK mode.
TrustArc(context: Context, sdkMode: SdkMode = Standard, onGoogleConsent: GoogleConsentsListener) DEPRECATED — Register Google consent callbacks via addGoogleConsentListener(...) instead.
Initialization Methods
Method Description Parameters Return
start Starts SDK initialization with domain and optional language. domainName: String, language: String? = "" void
start Starts SDK initialization with domain, optional country override, and optional language.

DEPRECATED — IP-based parameter.
domainName: String, country: String?, language: String? = "", ipAddress: String? = null void
start DEPRECATED — IP-based overload. domainName: String, ipAddress: String?, language: String? = "" void
start DEPRECATED — Callback overloads that include onConsent and onInitFinish. Use listeners instead. domainName/ipAddress/country with onConsent: Runnable?, onInitFinish: Runnable? void
Listener Methods
Method Description Parameters Return
addConsentListener Registers consent-change listener using category payload. Register before start(...). callback: (Map<String, TAConsent>) -> Unit void
removeConsentListener Unregisters a previously added consent listener. callback: (Map<String, TAConsent>) -> Unit void
addGoogleConsentListener Registers Google Consent Mode listener. Register before start(...). callback: GoogleConsentsListener void
addSdkInitializedListener Registers init-finish listener (no-args overload). callback: () -> Unit void
addSdkInitializedListener Registers init-finish listener (status-only overload). callback: (Boolean) -> Unit void
addSdkInitializedListener Registers init-finish listener (recommended overload with status and message). callback: (Boolean, String?) -> Unit void
Consent Management Methods
Method Description Parameters Return
openCM Manually opens the consent window. None void
openCM Opens the consent window with Domain ID and IP Address override.

DEPRECATED — No longer necessary to provide parameters. Domain, language, and IP address are already handled by the start() method.
domainName: Consent manager domain ID
ip: IP Address to override device IP (Optional)
void
openCMWithLanguage Opens the consent window with a specified language.

DEPRECATED — No longer necessary to provide parameters. Domain, language, and IP address are already handled by the start() method.
domainName: Consent manager domain ID
language: Locale to use (Optional)
ip: IP Address override (Optional)
void
Information Retrieval and Configuration Methods
Method Description Parameters Return
isConsentPresent Returns whether consent is stored on the device. None Boolean
getConsentValue Returns consent value for a tracker/domain ID. trackerId: String String?
getTrustArcDeviceUUID Returns the SDK-generated consent/device identifier. None String
getStoredConsentData Returns raw flat vendor consent list (domain-level approach). None List<VendorConsent>
getConsentDataByCategory Returns consent payload grouped by category (recommended approach). None Map<String, TAConsent>
isCategoryConsented Returns consent decision for a category index in category order. categoryIndex: Int Boolean
getCategoryConsent Returns category name and consent decision for a category index. categoryIndex: Int TACategoryConsent?
getLastConsent Returns last consent update timestamp. None Long
getStoredConsentExpiry Returns computed consent-expiry timestamp from stored settings. None String?
getConsentLanguage Returns language used for consent configuration. None String?
getWebScript Returns web script for web consent synchronization. None String?
getTcfString Returns stored IAB TCF string. None String?
getGoogleConsents Returns Google Consent Mode payload. None String?
getBehavior Returns behavior (implied or expressed). None String?
useGdprDetection Enables/disables automatic GDPR behavior detection. useGdprDetection: Boolean void
setUnifiedConsentContext Sets unified consent context before start/fetch. key: String void
setUnifiedConsentIdentity Sets unified identity for known user consent synchronization. userId: String, hmac: String void
fetchUnifiedConsentData Triggers manual unified consent fetch from backend. callback: Callback<ResponseBody> void
Debug and Testing Methods
Method Description Parameters Return
enableDebugLog Enables/disables SDK debug logs. enabled: Boolean void
generateHmacAuthId Testing-only helper to generate HMAC auth ID for unified consent workflows. userId: String, key: String String
TrustArcVendorConsentViewModel (Legacy)

TrustArcVendorConsentViewModel still exists in SDK sources but should be treated as legacy and not as the preferred integration path. Listener-based integration with addConsentListener is the current recommendation for consuming app developers.

Method Description Parameters Return
getVendorConsents Returns vendor consents as LiveData. None LiveData<List<VendorConsent>>
loadVendorConsents Manually refreshes vendor consent data. None void
TASharedInstance
Method Description Parameters Return
initSdk DEPRECATED — Constructor-style init with listener parameter. Prefer TrustArc(context, sdkMode) then addGoogleConsentListener(...). context: Context, sdkMode: SdkMode, googleConsentListener: GoogleConsentsListener void
setSdkInstance Assigns a TrustArc implementation to the singleton. trustArc: TrustArc void
getSdkInstance Returns the singleton TrustArc instance. None TrustArc
isSdkInitialized Returns true when singleton is initialized and assets are ready. None Boolean
IABTCFPreferences

Type definition for IAB TCF (Transparency & Consent Framework) preferences.

Field Description
IABTCF_PurposeOneTreatment Indicates if Purpose One has special treatment (0 = no, 1 = yes).
IABTCF_VendorConsents Encoded string representing vendor consents.
IABTCF_enableAdvertiserConsentMode Whether advertiser consent mode is enabled. Google's latest Firebase SDK for iOS and Android now supports TCF. To ensure proper consent handling, set IABTCF_enableAdvertiserConsentMode to 1 when using TCF so Google can infer consent from the TC string.
IABTCF_PublisherCC Publisher's country code (e.g., "DE", "FR").
IABTCF_PublisherConsent Encoded string representing publisher-specific consent.
IABTCF_gdprApplies Indicates if GDPR applies (0 = no, 1 = yes).
IABTCF_SpecialFeaturesOptIns Encoded string representing special feature opt-ins.
IABTCF_VendorLegitimateInterests Encoded string representing vendor legitimate interests.
IABTCF_PublisherLegitimateInterests Encoded string representing publisher legitimate interests.
IABTCF_PublisherCustomPurposesConsents Encoded string representing publisher custom purposes consents.
IABTCF_TCString TC string containing the encoded user consent data.
IABTCF_UseNonStandardTexts Indicates if non-standard text versions are used (0 = no, 1 = yes).
IABTCF_PolicyVersion IAB TCF policy version number.
IABTCF_PurposeConsents Encoded string representing purpose consents.
IABTCF_PurposeLegitimateInterests Encoded string representing purpose legitimate interests.
IABTCF_CmpSdkID CMP SDK ID.
IABTCF_CmpSdkVersion CMP SDK version.
IABTCF_PublisherCustomPurposesLegitimateInterests Encoded string representing publisher custom purposes legitimate interests.
TrustArc  ·  Mobile App Consent — API Reference: Android  ·  www.trustarc.com