目录

Scenario

Developers of media apps, ad platforms, and third-party tracking platforms can integrate the SDK of HUAWEI Ads Kit to obtain OAID information from Huawei devices. The OAID information can be used to recommend personalized ads to users and attribute ad conversions.

Precautions

  1. Ensure that your app has integrated the ads-identifier SDK in advance. For details, please refer to Preparations.
  2. Call getAdvertisingIdInfo to obtain OAID information. Do not call this API in the main thread.
  3. To protect user privacy, do not cache OAID information.

Development Procedure

Create a subthread and call the static AdvertisingIdClient.getAdvertisingIdInfo(mContext) method to obtain the OAID information. A sample code is as follows:

  1. /**
  2. * Obtain the OAID information in a non-UI thread.
  3. */
  4. private Thread getIdentifierThread = new Thread() {
  5.    @Override
  6.    public void run() {
  7.        try {
  8.            AdvertisingIdClient.Info info = AdvertisingIdClient.getAdvertisingIdInfo(mContext);
  9.            if (null != info) {
  10.                Log.i(TAG, "info id=" + info.getId() +
  11.                        ", isLimitAdTrackingEnabled=" + info.isLimitAdTrackingEnabled());
  12.            }
  13.        } catch (IOException e) {
  14.            Log.i(TAG, "getAdvertisingIdInfo Exception: " + e.toString());
  15.        }
  16.    }
  17. };