Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Quảng cáo
Thư viện mã nhận dạng cho quảng cáo (Advertising ID) xác định một giao diện để tương tác với nhà cung cấp quảng cáo ở cấp độ hệ thống trên thiết bị chạy ứng dụng của bạn. Giao diện này cho phép ứng dụng của bạn nhận được giá trị mã nhận dạng cố định cho quảng cáo.
Bản cập nhật mới nhất |
Bản phát hành ổn định |
Bản phát hành dùng thử |
Bản phát hành beta |
Bản phát hành alpha |
Ngày 8 tháng 3 năm 2023 |
- |
- |
- |
1.0.0-alpha05 |
Khai báo phần phụ thuộc
Để thêm một phần phụ thuộc trên Ads, bạn phải thêm kho lưu trữ Google Maven vào dự án. Đọc nội dung Kho lưu trữ Maven của Google để biết thêm thông tin.
Thêm các phần phụ thuộc cho cấu phần phần mềm bạn cần trong tệp build.gradle
cho ứng dụng hoặc mô-đun:
Groovy
dependencies {
implementation 'androidx.ads:ads-identifier:1.0.0-alpha05'
// Optional - add if you're using Guava to handle
// return values of type ListenableFuture.
implementation 'com.google.guava:guava:28.0-android'
}
Kotlin
dependencies {
implementation("androidx.ads:ads-identifier:1.0.0-alpha05")
// Optional - add if you're using Guava to handle
// return values of type ListenableFuture.
implementation("com.google.guava:guava:28.0-android")
}
Để biết thêm thông tin về các phần phụ thuộc, hãy xem bài viết Thêm phần phụ thuộc vào bản dựng.
Ý kiến phản hồi
Ý kiến phản hồi của bạn có thể giúp chúng tôi cải thiện Jetpack. Hãy cho chúng tôi biết nếu bạn phát hiện lỗi mới hoặc có ý tưởng cải thiện thư viện này. Vui lòng xem các lỗi hiện có trong thư viện này trước khi báo một lỗi mới. Bạn có thể thêm lượt bình chọn cho lỗi hiện có bằng cách nhấp vào nút dấu sao.
Báo lỗi mới
Hãy xem tài liệu về công cụ theo dõi lỗi để biết thêm thông tin.
Phiên bản 1.0.0
Phiên bản 1.0.0-alpha05
Ngày 8 tháng 3 năm 2023
Phát hành androidx.ads:ads-identifier:1.0.0-alpha05
, androidx.ads:ads-identifier-common:1.0.0-alpha05
và androidx.ads:ads-identifier-provider:1.0.0-alpha05
. Phiên bản 1.0.0-alpha05 bao gồm các thay đổi sau.
Thay đổi về API
Phiên bản 1.0.0-alpha04
Ngày 22 tháng 1 năm 2020
Phát hành androidx.ads:ads-identifier:1.0.0-alpha04
, androidx.ads:ads-identifier-common:1.0.0-alpha04
và androidx.ads:ads-identifier-provider:1.0.0-alpha04
. Phiên bản 1.0.0-alpha04 bao gồm các thay đổi sau.
Tính năng mới
Thay đổi API
AdvertisingIdInfo.getId()
nay trực tiếp trả về mã nhận dạng cho quảng cáo qua AdvertisingIdProvider
nên mã nhận dạng này có thể ở bất kỳ định dạng nào.
Phiên bản 1.0.0-alpha03
Ngày 20 tháng 11 năm 2019
Phát hành androidx.ads:ads-identifier:1.0.0-alpha03
và androidx.ads:ads-identifier-common:1.0.0-alpha03
. Phiên bản 1.0.0-alpha03 bao gồm các thay đổi sau.
Các bản sửa lỗi
- Xoá phần phụ thuộc trên ngôn ngữ lập trình Java 8. Thư viện này hiện hướng đến ngôn ngữ lập trình Java 7.
Phiên bản 1.0.0-alpha02
Ngày 18 tháng 9 năm 2019
Phát hành androidx.ads:ads-identifier:1.0.0-alpha02
và androidx.ads:ads-identifier-common:1.0.0-alpha02
. Phiên bản 1.0.0-alpha02 bao gồm các thay đổi sau.
Thay đổi API
- Thay đổi loại dữ liệu trả về của
AdvertisingIdUtils.getAdvertisingIdProviderServices()
từ List<ResolveInfo>
thành List<ServiceInfo>
Các bản sửa lỗi
- Thay đổi thông báo
AdvertisingIdNotAvailableException
để thể hiện nội dung chính xác hơn No compatible AndroidX Advertising ID Provider available" ("Không có nhà cung cấp mã nhận dạng AndroidX tương thích cho quảng cáo").
Phiên bản 1.0.0-alpha01
Ngày 7 tháng 8 năm 2019
Phát hành androidx.ads:ads-identifier:1.0.0-alpha01
,
androidx.ads:ads-identifier-common:1.0.0-alpha01
và
androidx.ads:ads-identifier-provider:1.0.0-alpha01
. Bạn có thể xem các thay đổi trong phiên bản này tại đây.
Nội dung và mã mẫu trên trang này phải tuân thủ các giấy phép như mô tả trong phần Giấy phép nội dung. Java và OpenJDK là nhãn hiệu hoặc nhãn hiệu đã đăng ký của Oracle và/hoặc đơn vị liên kết của Oracle.
Cập nhật lần gần đây nhất: 2025-07-27 UTC.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-07-27 UTC."],[],[],null,["# Ads\n===\n\n[User Guide](/training/articles/ad-id) \nAPI Reference \n[androidx.ads.identifier](/reference/androidx/ads/identifier/package-summary) \n[androidx.ads.identifier.provider](/reference/androidx/ads/identifier/provider/package-summary) \nThe Advertising ID library defines an interface to interact with system-level ad providers across the devices running your app. This interface allows your app to receive consistent advertising ID values. \n\n| Latest Update | Stable Release | Release Candidate | Beta Release | Alpha Release |\n|---------------|----------------|-------------------|--------------|---------------------------------------------------------------|\n| March 8, 2023 | - | - | - | [1.0.0-alpha05](/jetpack/androidx/releases/ads#1.0.0-alpha05) |\n\nDeclaring dependencies\n----------------------\n\nTo add a dependency on Ads, you must add the Google Maven repository to your\nproject. Read [Google's Maven repository](/studio/build/dependencies#google-maven)\nfor more information.\n\nAdd the dependencies for the artifacts you need in the `build.gradle` file for\nyour app or module: \n\n### Groovy\n\n```groovy\ndependencies {\n implementation 'androidx.ads:ads-identifier:1.0.0-alpha05'\n\n // Optional - add if you're using Guava to handle\n // return values of type ListenableFuture.\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-alpha05\")\n\n // Optional - add if you're using Guava to handle\n // return values of type ListenableFuture.\n implementation(\"com.google.guava:guava:28.0-android\")\n}\n```\n\nFor more information about dependencies, see [Add build dependencies](/studio/build/dependencies).\n\nFeedback\n--------\n\nYour feedback helps make Jetpack better. Let us know if you discover new issues or have\nideas for improving this library. Please take a look at the\n[existing issues](https://issuetracker.google.com/issues?q=componentid:807287%20status:open)\nin this library before you create a new one. You can add your vote to an existing issue by\nclicking the star button.\n\n[Create a new issue](https://issuetracker.google.com/issues/new?component=807287&template=1390045)\n\nSee the [Issue Tracker documentation](https://developers.google.com/issue-tracker)\nfor more information.\n\nVersion 1.0.0\n-------------\n\n### Version 1.0.0-alpha05\n\nMarch 8, 2023\n\n`androidx.ads:ads-identifier:1.0.0-alpha05`, `androidx.ads:ads-identifier-common:1.0.0-alpha05`, and `androidx.ads:ads-identifier-provider:1.0.0-alpha05` are released. [Version 1.0.0-alpha05 contains these commits.](https://android.googlesource.com/platform/frameworks/support/+log/0a3d894e8fe0217f1312fb163a89ad51bf15794e..ad9ba647b7548818fc9d4796a03a3b5510166fb3/ads)\n\n**API Changes**\n\n- Deprecated `androidx.ads:ads-identifier` \\& `androidx.ads:ads-identifier-provider`. Please migrate to the [Advertising ID API that's available as part of Google Play Services](https://developers.google.com/android/reference/com/google/android/gms/ads/identifier/AdvertisingIdClient) instead. ([I57791](https://android-review.googlesource.com/#/q/I57791965848891725f98e373d10708e1e525f334))\n\n### Version 1.0.0-alpha04\n\nJanuary 22, 2020\n\n`androidx.ads:ads-identifier:1.0.0-alpha04`, `androidx.ads:ads-identifier-common:1.0.0-alpha04`, and `androidx.ads:ads-identifier-provider:1.0.0-alpha04` are released. [Version 1.0.0-alpha04 contains these commits](https://android.googlesource.com/platform/frameworks/support/+log/73974afa0b122e423606439e6d8e249da523534e..0a3d894e8fe0217f1312fb163a89ad51bf15794e/ads).\n\n**New features**\n\n- Performance improvements.\n\n**API changes**\n\n- `AdvertisingIdInfo.getId()` now returns the Advertising ID from `AdvertisingIdProvider` directly, so the ID could be any format now.\n\n### Version 1.0.0-alpha03\n\nNovember 20, 2019\n\n`androidx.ads:ads-identifier:1.0.0-alpha03` and `androidx.ads:ads-identifier-common:1.0.0-alpha03` are released. [Version 1.0.0-alpha03 contains these commits](https://android.googlesource.com/platform/frameworks/support/+log/561afade39b67853e2b54301e6b0cd16d19ce0a7..73974afa0b122e423606439e6d8e249da523534e/ads).\n\n**Bug fixes**\n\n- Removed dependency on the Java 8 programming language. This library now targets the Java 7 programming language.\n\n### Version 1.0.0-alpha02\n\nSeptember 18, 2019\n\n`androidx.ads:ads-identifier:1.0.0-alpha02` and `androidx.ads:ads-identifier-common:1.0.0-alpha02` are released. [Version 1.0.0-alpha02 contains these commits](https://android.googlesource.com/platform/frameworks/support/+log/886c5f552be88f0d404fbae205244e074a75bb03..561afade39b67853e2b54301e6b0cd16d19ce0a7/ads).\n\n**API changes**\n\n- Changed the return type of `AdvertisingIdUtils.getAdvertisingIdProviderServices()` from `List\u003cResolveInfo\u003e` to `List\u003cServiceInfo\u003e`\n\n**Bug fixes**\n\n- Changed the `AdvertisingIdNotAvailableException` message to more accurately read \"No compatible AndroidX Advertising ID Provider available.\"\n\n### Version 1.0.0-alpha01\n\nAugust 7, 2019\n\n`androidx.ads:ads-identifier:1.0.0-alpha01`,\n`androidx.ads:ads-identifier-common:1.0.0-alpha01`, and\n`androidx.ads:ads-identifier-provider:1.0.0-alpha01` are released. The commits\nincluded in this version can be found\n[here](https://android.googlesource.com/platform/frameworks/support/+log/b2b23e833fc78420c0e1212c35ff1fbf9b327eaf..886c5f552be88f0d404fbae205244e074a75bb03/ads)."]]