AdvertisingIdClient.Info
Stay organized with collections
Save and categorize content based on your preferences.
Includes both the advertising ID as well as the limit ad tracking setting.
Public Constructor Summary
|
Info( String
advertisingId, boolean limitAdTrackingEnabled)
This constructor is deprecated. This constructor is not necessary for the
users to access the info.
|
Inherited Method Summary
From class java.lang.Object
Object
|
clone()
|
boolean |
|
void |
finalize()
|
final Class<?>
|
getClass()
|
int |
hashCode()
|
final void |
notify()
|
final void |
notifyAll()
|
String
|
toString()
|
final void |
wait(long arg0, int arg1)
|
final void |
wait(long arg0)
|
final void |
wait()
|
Public Constructors
public Info (String advertisingId, boolean
limitAdTrackingEnabled)
This constructor is deprecated.
This constructor is not necessary for the users to access the info.
Constructs an Info
Object with the specified advertising ID and limit
ad tracking setting.
Parameters
advertisingId |
The advertising ID. |
limitAdTrackingEnabled |
The limit ad tracking setting. It is true if the user has limit ad tracking
enabled. False, otherwise. |
Public Methods
public String getId ()
Retrieves the advertising ID.
Starting from late 2021, on Android 12 devices, when
isLimitAdTrackingEnabled()
is true
, the returned value of this
API will be 00000000-0000-0000-0000-000000000000
regardless of the app’s
target SDK level.
In early 2022, this change will be applied to all the devices that support Google
Play services.
Apps with target API level set to 33 (Android 13) or later must declare the normal
permission com.google.android.gms.permission.AD_ID
as below in the
AndroidManifest.xml in order to use this API.
- This permission will be granted when the app is installed.
- If this permission is not declared, the returned value will be
00000000-0000-0000-0000-000000000000
starting early 2022.
- Until then, to help developers, a warning line is logged if the permission is
missing when the app targets API level 33 (Android 13) or higher.This warning line
is under the
Log
tag
AdvertisingIdSettings
.
<uses-permission android:name="com.google.android.gms.permission.AD_ID"/>
If you need to prevent the permission from getting merged into your
app through dependencies such as SDKs, include the below element in your manifest
instead.
<uses-permission android:name="com.google.android.gms.permission.AD_ID"
tools:node="remove"/>
For apps with target API level set to 32 (Android 12L) or older, this permission is
not needed.
See Advertising ID Play
Console Help for more details.
public boolean isLimitAdTrackingEnabled ()
Retrieves whether the user has limit ad tracking enabled or not.
When the returned value is true
, the returned value of
getId()
will always be 00000000-0000-0000-0000-000000000000
starting with Android 12.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-12-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 2024-12-10 UTC."],[[["\u003cp\u003e\u003ccode\u003eAdvertisingIdClient.Info\u003c/code\u003e provides the advertising ID and limit ad tracking preference of a user.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003egetId()\u003c/code\u003e retrieves the advertising ID, which may be all zeros if limit ad tracking is enabled or the \u003ccode\u003eAD_ID\u003c/code\u003e permission is not declared for apps targeting Android 13 or higher.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eisLimitAdTrackingEnabled()\u003c/code\u003e indicates whether the user has opted out of personalized advertising.\u003c/p\u003e\n"],["\u003cp\u003eApps targeting Android 13 or higher need to declare the \u003ccode\u003ecom.google.android.gms.permission.AD_ID\u003c/code\u003e permission to access the advertising ID.\u003c/p\u003e\n"]]],["The `AdvertisingIdClient.Info` class provides access to the advertising ID and the user's limit ad tracking preference. Key actions include retrieving the advertising ID via `getId()`, which returns a string, and checking if ad tracking is limited using `isLimitAdTrackingEnabled()`, which returns a boolean. Starting with Android 12, when limit ad tracking is enabled, `getId()` returns all zeroes. Apps targeting Android 13 or later require the `com.google.android.gms.permission.AD_ID` permission to access the ID.\n"],null,["# AdvertisingIdClient.Info\n\npublic static final class **AdvertisingIdClient.Info** extends [Object](//developer.android.com/reference/java/lang/Object.html) \nIncludes both the advertising ID as well as the limit ad tracking setting. \n\n### Public Constructor Summary\n\n|---|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| | [Info](/android/reference/com/google/android/gms/ads/identifier/AdvertisingIdClient.Info#Info(java.lang.String,%20boolean))([String](//developer.android.com/reference/java/lang/String.html) advertisingId, boolean limitAdTrackingEnabled) *This constructor is deprecated. This constructor is not necessary for the users to access the info.* |\n\n### Public Method Summary\n\n|-------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [String](//developer.android.com/reference/java/lang/String.html) | [getId](/android/reference/com/google/android/gms/ads/identifier/AdvertisingIdClient.Info#getId())() Retrieves the advertising ID. |\n| boolean | [isLimitAdTrackingEnabled](/android/reference/com/google/android/gms/ads/identifier/AdvertisingIdClient.Info#isLimitAdTrackingEnabled())() Retrieves whether the user has limit ad tracking enabled or not. |\n| [String](//developer.android.com/reference/java/lang/String.html) | [toString](/android/reference/com/google/android/gms/ads/identifier/AdvertisingIdClient.Info#toString())() |\n\n### Inherited Method Summary\n\nFrom class java.lang.Object \n\n|----------------------------------------------------------------------------|--------------------------------------------------------------------------------|\n| [Object](//developer.android.com/reference/java/lang/Object.html) | clone() |\n| boolean | equals([Object](//developer.android.com/reference/java/lang/Object.html) arg0) |\n| void | finalize() |\n| final [Class](//developer.android.com/reference/java/lang/Class.html)\\\u003c?\\\u003e | getClass() |\n| int | hashCode() |\n| final void | notify() |\n| final void | notifyAll() |\n| [String](//developer.android.com/reference/java/lang/String.html) | toString() |\n| final void | wait(long arg0, int arg1) |\n| final void | wait(long arg0) |\n| final void | wait() |\n\nPublic Constructors\n-------------------\n\n#### public **Info** ([String](//developer.android.com/reference/java/lang/String.html) advertisingId, boolean limitAdTrackingEnabled)\n\n**This constructor is deprecated.** \n\nThis constructor is not necessary for the users to access the info. \nConstructs an `Info` Object with the specified advertising ID and limit\nad tracking setting. \n\n##### Parameters\n\n| advertisingId | The advertising ID. |\n| limitAdTrackingEnabled | The limit ad tracking setting. It is true if the user has limit ad tracking enabled. False, otherwise. |\n|------------------------|--------------------------------------------------------------------------------------------------------|\n\nPublic Methods\n--------------\n\n#### public [String](//developer.android.com/reference/java/lang/String.html) **getId** ()\n\nRetrieves the advertising ID.\n\nStarting from late 2021, on Android 12 devices, when [isLimitAdTrackingEnabled()](/android/reference/com/google/android/gms/ads/identifier/AdvertisingIdClient.Info#isLimitAdTrackingEnabled()) is `true`, the returned value of this\nAPI will be `00000000-0000-0000-0000-000000000000` regardless of the app's\ntarget SDK level.\n\nIn early 2022, this change will be applied to all the devices that support Google\nPlay services.\n\nApps with target API level set to 33 (Android 13) or later must declare the [normal](//developer.android.com/guide/topics/permissions/overview#normal)\npermission `com.google.android.gms.permission.AD_ID` as below in the\nAndroidManifest.xml in order to use this API.\n\n- This permission will be granted when the app is installed.\n- If this permission is not declared, the returned value will be `00000000-0000-0000-0000-000000000000` starting early 2022.\n- Until then, to help developers, a warning line is logged if the permission is missing when the app targets API level 33 (Android 13) or higher.This warning line is under the [Log](//developer.android.com/reference/android/util/Log.html) tag `AdvertisingIdSettings`.\n\n \u003cuses-permission android:name=\"com.google.android.gms.permission.AD_ID\"/\u003e\n\nIf you need to prevent the permission from getting [merged](//developer.android.com/studio/build/manifest-merge#node_markers) into your\napp through dependencies such as SDKs, include the below element in your manifest\ninstead. \n\n \u003cuses-permission android:name=\"com.google.android.gms.permission.AD_ID\"\n tools:node=\"remove\"/\u003e\n\nFor apps with target API level set to 32 (Android 12L) or older, this permission is\nnot needed.\n\nSee [Advertising ID Play\nConsole Help](//support.google.com/googleplay/android-developer/answer/6048248) for more details. \n\n#### public boolean **isLimitAdTrackingEnabled** ()\n\nRetrieves whether the user has limit ad tracking enabled or not.\n\nWhen the returned value is `true`, the returned value of [getId()](/android/reference/com/google/android/gms/ads/identifier/AdvertisingIdClient.Info#getId()) will always be `00000000-0000-0000-0000-000000000000`\nstarting with Android 12. \n\n#### public [String](//developer.android.com/reference/java/lang/String.html) **toString** ()"]]