Stay organized with collections
Save and categorize content based on your preferences.
AdId
open class AdId
A unique, user-resettable, device-wide, per-profile ID for advertising.
Ad networks may use AdId
to monetize for Interest Based Advertising (IBA), i.e. targeting and remarketing ads. The user may limit availability of this identifier.
Summary
Public constructors |
Creates an instance of AdId
|
Constants
ZERO_OUT
static val ZERO_OUT: String
A zeroed-out ad id
that is returned when the user has limited ad tracking
.
Value: "00000000-0000-0000-0000-000000000000"
Public constructors
AdId
AdId(
adId: String,
limitAdTrackingEnabled: Boolean)
Creates an instance of AdId
Parameters |
adId |
String: obtained from the provider service. This value cannot be null . |
limitAdTrackingEnabled |
Boolean: value from the provider service which determines the value of adId. |
Public methods
equals
open fun equals(other: Any?): Boolean
Parameters |
obj |
the reference object with which to compare. |
Return |
Boolean |
true if this object is the same as the obj argument; false otherwise. |
hashCode
open fun hashCode(): Int
Return |
Int |
a hash code value for this object. |
isLimitAdTrackingEnabled
open fun isLimitAdTrackingEnabled(): Boolean
Retrieves the limit ad tracking enabled setting.
This value is true if user has limit ad tracking enabled, false
otherwise.
toString
open fun toString(): String
Return |
String |
a string representation of the object. |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# AdId\n\nAdded in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \nAlso in [Ad Services Extensions 4](https://developer.android.com/sdkExtensions)\n\nAdId\n====\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/adservices/adid/AdId \"View this page in Java\") \n\n```\nopen class AdId\n```\n\n|---|-----------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||\n| ↳ | [android.adservices.adid.AdId](#) |\n\nA unique, user-resettable, device-wide, per-profile ID for advertising.\n\nAd networks may use `AdId` to monetize for Interest Based Advertising (IBA), i.e. targeting and remarketing ads. The user may limit availability of this identifier.\n\nSummary\n-------\n\n| Constants ||\n|-----------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| static [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | [ZERO_OUT](#ZERO_OUT:kotlin.String) A zeroed-out [ad id](#getAdId()) that is returned when the user has [limited ad tracking](#isLimitAdTrackingEnabled()). |\n\n| Public constructors ||\n|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|\n| [AdId](#AdId(kotlin.String,%20kotlin.Boolean))`(`adId:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, `limitAdTrackingEnabled:` `[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)`)` Creates an instance of [AdId](#) |\n\n| Public methods ||\n|-----------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------|\n| open [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | [equals](#equals(kotlin.Any))`(`other:` `[Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)?`)` \u003cbr /\u003e |\n| open [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | [getAdId](#getAdId())`()` The advertising ID. |\n| open [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [hashCode](#hashCode())`()` \u003cbr /\u003e |\n| open [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | [isLimitAdTrackingEnabled](#isLimitAdTrackingEnabled())`()` Retrieves the limit ad tracking enabled setting. |\n| open [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | [toString](#toString())`()` \u003cbr /\u003e |\n\nConstants\n---------\n\n### ZERO_OUT\n\nAdded in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \nAlso in [Ad Services Extensions 4](https://developer.android.com/sdkExtensions) \n\n```\nstatic val ZERO_OUT: String\n```\n\nA zeroed-out [ad id](#getAdId()) that is returned when the user has [limited ad tracking](#isLimitAdTrackingEnabled()). \n\n Value: \"00000000-0000-0000-0000-000000000000\"\n\nPublic constructors\n-------------------\n\n### AdId\n\nAdded in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \nAlso in [Ad Services Extensions 4](https://developer.android.com/sdkExtensions) \n\n```\nAdId(\n adId: String, \n limitAdTrackingEnabled: Boolean)\n```\n\nCreates an instance of [AdId](#)\n\n| Parameters ||\n|--------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `adId` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html): obtained from the provider service. This value cannot be `null`. |\n| `limitAdTrackingEnabled` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html): value from the provider service which determines the value of adId. |\n\nPublic methods\n--------------\n\n### equals\n\nAdded in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun equals(other: Any?): Boolean\n```\n\n| Parameters ||\n|-------|---------------------------------------------|\n| `obj` | the reference object with which to compare. |\n\n| Return ||\n|------------------------------------------------------------------------------------|---------------------------------------------------------------------------|\n| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | `true` if this object is the same as the obj argument; `false` otherwise. |\n\n### getAdId\n\nAdded in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \nAlso in [Ad Services Extensions 4](https://developer.android.com/sdkExtensions) \n\n```\nopen fun getAdId(): String\n```\n\nThe advertising ID.\n\nThe value of advertising Id depends on a combination of [isLimitAdTrackingEnabled()](#isLimitAdTrackingEnabled()) and [android.adservices.common.AdServicesPermissions#ACCESS_ADSERVICES_AD_ID](../common/AdServicesPermissions.html#ACCESS_ADSERVICES_AD_ID:kotlin.String).\n\nWhen the user is [limiting ad tracking](#isLimitAdTrackingEnabled()), the API returns [ZERO_OUT](#ZERO_OUT:kotlin.String). This disallows a caller to track the user for monetization purposes.\n\nOtherwise, a string unique to the device and user is returned, which can be used to track users for advertising.\n\n| Return ||\n|----------------------------------------------------------------------------------|------------------------------|\n| [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | This value cannot be `null`. |\n\n### hashCode\n\nAdded in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun hashCode(): Int\n```\n\n| Return ||\n|----------------------------------------------------------------------------|------------------------------------|\n| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | a hash code value for this object. |\n\n### isLimitAdTrackingEnabled\n\nAdded in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \nAlso in [Ad Services Extensions 4](https://developer.android.com/sdkExtensions) \n\n```\nopen fun isLimitAdTrackingEnabled(): Boolean\n```\n\nRetrieves the limit ad tracking enabled setting.\n\nThis value is true if user has limit ad tracking enabled, `false` otherwise. \n\n### toString\n\nAdded in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun toString(): String\n```\n\n| Return ||\n|----------------------------------------------------------------------------------|----------------------------------------|\n| [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | a string representation of the object. |"]]