AdvertisingIdClient
public
class
AdvertisingIdClient
extends Object
java.lang.Object | |
↳ | androidx.ads.identifier.AdvertisingIdClient |
Client for retrieving Advertising ID related info from an AndroidX ID Provider installed on the device.
Typical usage would be:
- Call
isAdvertisingIdProviderAvailable(Context)
to make sure there is an Advertising ID Provider available. - Call
getAdvertisingIdInfo(Context)
to get Advertising ID info (the Advertising ID and LAT setting).
Summary
Public methods | |
---|---|
static
ListenableFuture<AdvertisingIdInfo>
|
getAdvertisingIdInfo(Context context)
Retrieves the user's Advertising ID info. |
static
boolean
|
isAdvertisingIdProviderAvailable(Context context)
Checks whether there is any Advertising ID Provider installed on the device. |
Inherited methods | |
---|---|
Public methods
getAdvertisingIdInfo
public static ListenableFuture<AdvertisingIdInfo> getAdvertisingIdInfo (Context context)
Retrieves the user's Advertising ID info.
When multiple Advertising ID Providers are installed on the device, this method will always return the Advertising ID information from same Advertising ID Provider for all apps which use this library, using following priority:
- System-level providers with "androidx.ads.identifier.provider.HIGH_PRIORITY" permission
- Other system-level providers
If there are ties in any of the above categories, it will use this priority:
- First app by earliest install time
(
PackageInfo.firstInstallTime
) - First app by package name alphabetically sorted
Parameters | |
---|---|
context |
Context : Current Context (such as the current Activity ). |
Returns | |
---|---|
ListenableFuture<AdvertisingIdInfo> |
A ListenableFuture that will be fulfilled with a AdvertisingIdInfo
which contains the user's Advertising ID info, or rejected with the following exceptions,
|
isAdvertisingIdProviderAvailable
public static boolean isAdvertisingIdProviderAvailable (Context context)
Checks whether there is any Advertising ID Provider installed on the device.
This method does a quick check for the Advertising ID providers.
Note: Even if this method returns true, there is still a possibility that the
getAdvertisingIdInfo(Context)
method throws an exception for some reason.
Parameters | |
---|---|
context |
Context : Current Context (such as the current Activity ). |
Returns | |
---|---|
boolean |
whether there is an Advertising ID Provider available on the device. |