사용자 개인 정보 보호를 위해 모든 Android 앱은
사용자가 재설정할 수 있는 식별자 이와 같은 식별자 중 하나가 광고 ID이며 광고 개인 최적화와 같은 광고 사용 사례를 위한 특정 사용자를 고유하게 식별합니다.
앱을 실행하는 기기에서 표준화된 광고 추적 솔루션을 지원하려면 광고 ID 라이브러리를 사용하면 됩니다.
이 라이브러리는 Android 4.0(API 수준 14) 이상을 실행하는 기기에서 사용할 수 있고 인터페이스를 정의하여 시스템 수준 광고 제공자와 상호작용합니다.
이 인터페이스를 통해 앱은 일관된 광고 ID 값을 받을 수 있습니다.
광고 ID 라이브러리에 포함된 광고 제공자는 광고 제공자가 구현하는 설정 화면을 열기 위한 표준 인텐트도 정의합니다.
설정 화면에서 사용자는 광고 ID를 재설정하고 광고 개인 최적화를 선택 해제할 수 있습니다.
이 가이드에서는 광고 ID 라이브러리의 클라이언트 모듈을 사용하는 방법을 설명합니다.
기기 사용자별로 일관된 광고 ID를 얻을 수 있습니다. 또한 라이브러리의 아키텍처를 간단하게 보여줍니다.
클라이언트 앱 구성
앱은 광고 ID 라이브러리의 클라이언트 모듈과 상호작용하여 앱과 상호작용하는 사용자를 나타내는 일관된 광고 ID를 검색할 수 있습니다.
다음 코드 스니펫은 광고 ID를 검색하는 방법을 보여줍니다.
광고 제공업체에서 제공하는 다른 정보도 확인할 수 있습니다.
app/build.gradle
Groovy
dependencies{implementation'androidx.ads:ads-identifier:1.0.0-alpha01'// Used for the calls to addCallback() in the snippets on this page.implementation'com.google.guava:guava:28.0-android'}
Kotlin
dependencies{implementation("androidx.ads:ads-identifier:1.0.0-alpha01")// Used for the calls to addCallback() in the snippets on this page.implementation("com.google.guava:guava:28.0-android")}
MyAdIdClient
Kotlin
// Used for the call to addCallback() within this snippet.importcom.google.common.util.concurrent.Futures.addCallbackprivatefundetermineAdvertisingInfo(){if(AdvertisingIdClient.isAdvertisingIdProviderAvailable()){valadvertisingIdInfoListenableFuture=AdvertisingIdClient.getAdvertisingIdInfo(applicationContext)addCallback(advertisingIdInfoListenableFuture,object:FutureCallback<AdvertisingIdInfo>{overridefunonSuccess(adInfo:AdvertisingIdInfo?){valid:String=adInfo?.idvalproviderPackageName:String=adInfo?.providerPackageNamevalisLimitTrackingEnabled:Boolean=adInfo?.isLimitTrackingEnabled}// Any exceptions thrown by getAdvertisingIdInfo()// cause this method to be called.overridefunonFailure(t:Throwable){Log.e("MY_APP_TAG","Failed to connect to Advertising ID provider.")// Try to connect to the Advertising ID provider again or fall// back to an ad solution that doesn't require using the// Advertising ID library.}},Executors.newSingleThreadExecutor())}else{// The Advertising ID client library is unavailable. Use a different// library to perform any required ad use cases.}}
자바
// Used for the call to addCallback() within this snippet.importcom.google.common.util.concurrent.Futures;privatevoiddetermineAdvertisingInfo(){if(AdvertisingIdClient.isAdvertisingIdProviderAvailable()){ListenableFuture<AdvertisingIdInfo>advertisingIdInfoListenableFuture=AdvertisingIdClient.getAdvertisingIdInfo(getApplicationContext());Futures.addCallback(advertisingIdInfoListenableFuture,newFutureCallback<AdvertisingIdInfo>(){@OverridepublicvoidonSuccess(AdvertisingIdInfoadInfo){Stringid=adInfo.getId();StringproviderPackageName=adInfo.getProviderPackageName();booleanisLimitTrackingEnabled=adInfo.isLimitTrackingEnabled();// Any exceptions thrown by getAdvertisingIdInfo()// cause this method to be called.@OverridepublicvoidonFailure(Throwablethrowable){Log.e("MY_APP_TAG","Failed to connect to Advertising ID provider.");// Try to connect to the Advertising ID provider again// or fall back to an ad solution that doesn't require// using the Advertising ID library.}});}else{// The Advertising ID client library is unavailable. Use a different// library to perform any required ad use cases.}}
광고 ID 라이브러리 아키텍처
그림 1. 광고 ID 라이브러리 아키텍처를 통해 개인정보처리방침을 정의할 수 있습니다.
그림 1은 광고 ID 라이브러리의 구조를 보여줍니다.
라이브러리는 다음 모듈로 구성됩니다.
클라이언트 모듈: 앱에 포함된 얇은 레이어
제공자 모듈: 기기 제조업체에서 제공.
이 모듈의 구현에서는 설정 UI를 정의하여 사용자에게
광고 ID를 재설정하고 광고 추적 환경설정을 전환할 수 있습니다.
클라이언트 모듈은 제공자 모듈과 통신하여 광고 추적 관련 광고 ID와 사용자 환경설정을 검색합니다.
라이브러리가 여러 제공자를 처리하는 방법
한 기기에서 여러 시스템 수준 광고 제공자를 지원하는 것은
할 수 있습니다. 광고 ID 라이브러리가 이러한 상황을 감지하면
여러분의 앱은 항상 같은 제공자로부터 정보를 검색한다는 전제하에
계속 사용할 수 있습니다 이 프로세스를 통해 광고 ID의 일관성이 유지됩니다.
사용 가능한 광고 제공자 세트가 시간이 지남에 따라 변경되어 앱에서 다른 광고 식별자 제공자와 상호작용하면 다른 모든 클라이언트 앱에서도 그러한 새 제공자를 사용하기 시작합니다. 앱은 사용자가 광고 ID 재설정을 요청하면 발생할 수 있는 동작을 동일하게 보여줍니다.
광고 ID 제공자 라이브러리는 다음과 같은 결정론적인 순서를 사용하여 제공자의 순위를 정합니다.
androidx.ads.identifier.provider.HIGH_PRIORITY 권한
가장 오래 기기에 설치된 제공자
알파벳 순서에서 처음 표시되는 제공자
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 OpenJDK는 Oracle 및 Oracle 계열사의 상표 또는 등록 상표입니다.
최종 업데이트: 2025-07-27(UTC)
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-07-27(UTC)"],[],[],null,["Get a user-resettable advertising ID Part of [Android Jetpack](/jetpack).\n=========================================================================\n\n| **Note:** If you plan to publish and distribute your app using Google Play, use the [ads identifier\n| library](https://developers.google.com/android/reference/com/google/android/gms/ads/identifier/AdvertisingIdClient) that's available as part of Google Play services instead of this library.\n\nTo protect user privacy, it's a best practice for all Android apps to work with\nuser-resettable identifiers. One such identifier is an *advertising ID*, which\nuniquely identifies a particular user for advertising use cases, such as ad\npersonalization.\n\nTo support a standardized ad-tracking solution across the devices running your\napp, you can use the [Advertising ID library](/jetpack/androidx/releases/ads).\nThis library, which is available on devices running Android 4.0 (API level 14)\nand higher, defines an interface to interact with system-level ad providers.\nThis interface allows your app to receive consistent advertising ID values.\n\nThe ad provider that's included with the Advertising ID library also defines a\nstandard intent for opening a settings screen that the ad provider implements.\nThis settings screen allows the user to reset their advertising ID and opt out\nof ad personalization.\n\nThis guide explains how to use the client module of the Advertising ID library\nto obtain a consistent advertising ID on a per-device-user basis. This guide\nthen presents an overview of the library's architecture.\n\nConfigure your client app\n-------------------------\n\nBy interacting with the client module of the Advertising ID library, your app\ncan retrieve a consistent advertising ID that represents the user who is\ninteracting with the app.\n\nThe advertising ID is represented using version 3 of the [universally unique\nidentifier (UUID)\nformat](https://www.rfc-editor.org/rfc/rfc4122.txt) or an\nequivalent 128-bit format: \n\n```\n38400000-8cf0-11bd-b23e-10b96e40000d\n```\n\nThe Advertising ID library normalizes the return value as necessary to provide\nIDs using this format.\n| **Note:** Most ad providers make sure that the advertising ID is unique *per device\n| user*. On Android devices that support multiple users, including guest users, it's possible for your app to obtain different advertising IDs on the same device. These different IDs correspond to different users who could be signed in on that device.\n\nTo retrieve the user-resettable advertising ID for your app, complete the\nfollowing steps:\n\n1. Check whether an ad provider is available by calling\n [`AdvertisingIdClient.isAdvertisingIdProviderAvailable()`](/reference/androidx/ads/identifier/AdvertisingIdClient#isAdvertisingIdProviderAvailable(android.content.Context)).\n If this method returns\n `false`, your app should use another means to perform any required ad-tracking\n use cases.\n\n | **Caution:** Even if this method returns `true`, your app should be able to handle any exceptions that could occur when attempting to retrieve the advertising ID.\n2. Get the ad identifier details, including the advertising ID, by calling\n [`AdvertisingIdClient.getAdvertisingIdInfo()`](/reference/androidx/ads/identifier/AdvertisingIdClient#getAdvertisingIdInfo(android.content.Context)). The Advertising ID library\n executes this method on a worker thread and uses a 10-second connection timeout.\n\n | **Note:** Because the user can reset their advertising ID after your app starts, you should call `AdvertisingIdClient.getAdvertisingIdInfo()` each time your app needs to check the value of the ID. Don't cache the value.\n\nThe following code snippet demonstrates how to retrieve the advertising ID\nalong with other information from the ad provider:\n\napp/build.gradle \n\n### Groovy\n\n```groovy\ndependencies {\n implementation 'androidx.ads:ads-identifier:1.0.0-alpha01'\n\n // Used for the calls to addCallback() in the snippets on this page.\n implementation 'com.google.guava:guava:28.0-android'\n}\n```\n\n### Kotlin\n\n```kotlin\ndependencies {\n implementation(\"androidx.ads:ads-identifier:1.0.0-alpha01\")\n\n // Used for the calls to addCallback() in the snippets on this page.\n implementation(\"com.google.guava:guava:28.0-android\")\n}\n```\n\nMyAdIdClient \n\n### Kotlin\n\n```kotlin\n// Used for the call to addCallback() within this snippet.\nimport com.google.common.util.concurrent.Futures.addCallback\n\nprivate fun determineAdvertisingInfo() {\n if (AdvertisingIdClient.isAdvertisingIdProviderAvailable()) {\n val advertisingIdInfoListenableFuture =\n AdvertisingIdClient.getAdvertisingIdInfo(applicationContext)\n\n addCallback(advertisingIdInfoListenableFuture,\n object : FutureCallback\u003cAdvertisingIdInfo\u003e {\n override fun onSuccess(adInfo: AdvertisingIdInfo?) {\n val id: String = adInfo?.id\n val providerPackageName: String = adInfo?.providerPackageName\n val isLimitTrackingEnabled: Boolean =\n adInfo?.isLimitTrackingEnabled\n }\n\n // Any exceptions thrown by getAdvertisingIdInfo()\n // cause this method to be called.\n override fun onFailure(t: Throwable) {\n Log.e(\"MY_APP_TAG\",\n \"Failed to connect to Advertising ID provider.\")\n // Try to connect to the Advertising ID provider again or fall\n // back to an ad solution that doesn't require using the\n // Advertising ID library.\n }\n }, Executors.newSingleThreadExecutor())\n } else {\n // The Advertising ID client library is unavailable. Use a different\n // library to perform any required ad use cases.\n }\n}\n```\n\n### Java\n\n```java\n// Used for the call to addCallback() within this snippet.\nimport com.google.common.util.concurrent.Futures;\n\nprivate void determineAdvertisingInfo() {\n if (AdvertisingIdClient.isAdvertisingIdProviderAvailable()) {\n ListenableFuture\u003cAdvertisingIdInfo\u003e advertisingIdInfoListenableFuture =\n AdvertisingIdClient.getAdvertisingIdInfo(getApplicationContext());\n Futures.addCallback(advertisingIdInfoListenableFuture,\n new FutureCallback\u003cAdvertisingIdInfo\u003e() {\n @Override\n public void onSuccess(AdvertisingIdInfo adInfo) {\n String id = adInfo.getId();\n String providerPackageName =\n adInfo.getProviderPackageName();\n boolean isLimitTrackingEnabled =\n adInfo.isLimitTrackingEnabled();\n\n // Any exceptions thrown by getAdvertisingIdInfo()\n // cause this method to be called.\n @Override\n public void onFailure(Throwable throwable) {\n Log.e(\"MY_APP_TAG\",\n \"Failed to connect to Advertising ID provider.\");\n // Try to connect to the Advertising ID provider again\n // or fall back to an ad solution that doesn't require\n // using the Advertising ID library.\n }\n });\n } else {\n // The Advertising ID client library is unavailable. Use a different\n // library to perform any required ad use cases.\n }\n}\n```\n\nAdvertising ID library architecture\n-----------------------------------\n\n**Figure 1.** Advertising ID library architecture\n\nFigure 1 depicts the structure of the Advertising ID library.\nThe library consists of the following modules:\n\n- A *client module*, which is a thin layer included in apps.\n- A *provider module*, which the device manufacturer makes available. Implementations of this module must define a settings UI to give users the ability to reset their advertising ID and toggle ad tracking preferences.\n\nThe client module communicates with the provider module to retrieve advertising\nIDs and user preferences regarding ad tracking.\n\n### How the library handles multiple providers\n\nIt's possible for a device to support multiple system-level ad providers at the\nsame time. If the Advertising ID library detects this situation, it ensures that\nyour app always retrieves information from the same provider, assuming that the\nprovider remains available. This process keeps the advertising ID consistent.\n\nIf the set of available ad providers changes over time and your app\ninteracts with a different ad identifier provider, all other client apps start\nusing that new provider as well. Your app demonstrates the same behavior that\nwould occur if the user had requested to reset their advertising ID.\n\nThe Advertising ID provider library uses the following deterministic order to\nrank the providers:\n\n1. Providers that have requested the `androidx.ads.identifier.provider.HIGH_PRIORITY` permission.\n2. Providers that have been installed on the device for the longest time.\n3. Providers that appear first in alphabetical order."]]