Google is committed to advancing racial equity for Black communities. See how.

AdvertisingIdClient.Info

public static final class AdvertisingIdClient.Info extends Object

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.

Public Method Summary

String
getId()
Retrieves the advertising ID.
boolean
isLimitAdTrackingEnabled()
Retrieves whether the user has limit ad tracking enabled or not.
String

Inherited Method Summary

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 31 (Android 12) or later must declare the normal permission com.google.android.gms.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 31 (Android 12) 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 30 (Android 11) 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.

public String toString ()