Summary: Nested Classes | Methods | Inherited Methods | [Expand All]
public class

# AdvertisingIdClient

extends Object

java.lang.Object
↳ | com.google.android.gms.ads.identifier.AdvertisingIdClient

## Class Overview

Helper library for retrieval of advertising ID and related information such as the limit ad tracking setting.

It is intended that the advertising ID completely replace existing usage of other identifiers for ads purposes (such as use of `ANDROID_ID` in `Settings.Secure`) when Google Play Services is available. Cases where Google Play Services is unavailable are indicated by a `GooglePlayServicesNotAvailableException` being thrown by getAdvertisingIdInfo().

## Summary

Nested Classes
class | AdvertisingIdClient.Info | Includes both the advertising ID as well as the limit ad tracking setting.

Public Methods
static AdvertisingIdClient.Info | getAdvertisingIdInfo(Context context) Retrieves the user's advertising ID and limit ad tracking preference.

[Expand] Inherited Methods
From class java.lang.Object
Object | clone()
boolean | equals(Object arg0)
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 Methods

#### public static AdvertisingIdClient.Info getAdvertisingIdInfo (Context context)

Retrieves the user's advertising ID and limit ad tracking preference.

This method cannot be called in the main thread as it may block leading to ANRs. An `IllegalStateException` will be thrown if this is called on the main thread.

##### Parameters

context | Current `Context` (such as the current `Activity`).

##### Returns

- AdvertisingIdClient.Info with user's advertising ID and limit ad tracking preference.

##### Throws

IOException | signaling connection to Google Play Services failed.
IllegalStateException | indicating this method was called on the main thread.
GooglePlayServicesNotAvailableException | indicating that Google Play is not installed on this device.
GooglePlayServicesRepairableException | indicating that there was a recoverable error connecting to Google Play Services.