识别开发者拥有的 App(App set ID)| Android 开发者文档 原文标题:Identify developer-owned apps | Identity | Android Developers
内容概要总结
Android 官方对 app set ID(应用集 ID)的说明页。当你在某台设备上需要跨自有组织的一组 App 关联使用行为或操作(例如分析、反欺诈)时,Google Play services 提供了一个对隐私友好的方案——app set ID。
app set ID 有两种作用域,可通过 getScope() 判断:Google Play developer scope(开发者作用域)——由 Google Play 商店安装的 App,其 ID 以同一 Google Play 开发者账号下发布的一组 App 为范围,同账号下的 App 即使由不同密钥签名也共享同一 ID;App scope(App 作用域)——当 App 由非 Google Play 商店的安装器安装、Google Play services 无法确定 App 的 Google Play 开发者账号、或设备没有 Google Play services 时,返回仅对调用 App 自身唯一的 ID。
文档强调不要依赖缓存的 app set ID 值:当某组共享同一 ID 的 App 超过 13 个月未访问该 API、该组中最后一个 App 被卸载、或用户恢复出厂设置时,ID 可能被重置;从仅支持 app scope 的版本升级到支持 developer scope 的版本时,ID 值会自动重置。App 必须在每次需要时用 SDK 重新获取。文中给出依赖引入(play-services-appset:16.1.0)与异步获取示例代码。
翻译内容
原文内容(English)
对于在给定设备上的分析或反欺诈等用例,你可能需要跨自有组织拥有的一组 App 关联其使用行为或操作。Google Play services 提供了一个对隐私友好的选项,称为 app set ID(应用集 ID)。
App set ID 的作用域
app set ID 可以有以下已定义的作用域之一。要确定某个特定 ID 关联的是哪个作用域,请调用 getScope()。
注意:当 Google Play services 从仅支持 app scope 的版本更新到支持 developer scope 的版本时,app set ID 的值会自动重置,无需开发者做任何操作。开发者不应依赖缓存的 app set ID 值的其他原因见下文。
Google Play developer scope(开发者作用域)
注意:除非 App 满足下文「App scope」一节所述的条件,app set SDK 会在无需开发者额外操作的情况下,尝试返回具有 developer scope 的 app set ID。
对于由 Google Play 商店安装的 App,app set ID API 返回的 ID 以同一 Google Play 开发者账号下发布的一组 App 为作用域。
例如,假设你在自己的 Google Play 开发者账号下发布两个 App,且这两个 App 都通过 Google Play 商店安装在同一台设备上。那么这两个 App 在该设备上共享同一个 app set ID。即使这两个 App 由不同的密钥签名,该 ID 也相同。
App scope(App 作用域)
在以下任一条件下,app set ID SDK 会返回一个在给定设备上仅对调用 App 自身唯一的 ID:
- App 由 Google Play 商店以外的安装器安装。
- Google Play services 无法确定某 App 的 Google Play 开发者账号。
- App 安装在没有 Google Play services 的设备上。
不要依赖缓存的 app set ID 值
在以下任一条件下,某台设备上一组由 Google Play 商店安装的 App 的 app set ID 可能被重置:
- 共享同一 ID 值的这组 App 超过 13 个月未访问 app set ID API。
- 某组 App 中的最后一个 App 从设备上被卸载。
- 用户对设备执行恢复出厂设置。
你的 App 必须在每次需要时使用 SDK 获取该 ID 值。
将 app set ID SDK 添加到你的 App
以下代码片段展示了一个使用 app set ID 库的 build.gradle 文件示例:
dependencies {
implementation 'com.google.android.gms:play-services-appset:16.1.0'
}
以下示例代码片段演示了如何使用 Google Play services 中的 Tasks API 异步获取 app set ID:
val client = AppSet.getClient(applicationContext) as AppSetIdClient
val task: Task<AppSetIdInfo> = client.appSetIdInfo as Task<AppSetIdInfo>
task.addOnSuccessListener({
// 确定 app set ID 的当前作用域。
val scope: Int = it.scope
// 读取 app set ID 值,该值使用
// 通用唯一标识符(UUID)格式的第 4 版。
val id: String = it.id
})
关于 UUID 格式的更多信息,请参阅「通用唯一标识符(Universally unique identifier)」。
本页内容与代码示例受「Content License」中所述许可的约束。Java 和 OpenJDK 是 Oracle 和/或其关联公司的商标或注册商标。
最后更新于 2026-10-08 UTC。
Skip to main content
Essentials
Design & Plan
Develop
Google Play
Blog
More
Android Studio
Sign in
SECURITY
IDENTITY
Overview
Samples
Guides
More
Credential Manager overview
About Credential Manager
Prerequisites
Authenticate users
Authenticate with passkeys
Authenticate with Sign in with Google
Authenticate with passwords
Restore credentials on new devices
Advanced features and integrations
Migrate to Credential Manager
Authenticate across form factors
Implement authentication as a credential provider
Troubleshoot common errors
Credential Manager FAQ
Show a biometric authentication dialog
Block Store
Legacy APIs
Authorize users
Authorize user access
Use digital credentials
About digital credentials
Integrate your holder app with Credential Manager
Integrate your verifier app with Credential Manager
Issue credentials with Credential Manager
Verify phone numbers with digital credentials
Verify email addresses with digital credentials
Verify users
Automate SMS verification
Provide phone number hints to users
Handle user data
Autofill personal information
Identify developer-owned apps
Manage user data
On this page
App set ID scope
Google Play developer scope
App scope
Don't rely on a cached value of app set ID
Add the app set ID SDK to your app
Android Developers
Design & Plan
Security
Identity
Guides
Identify developer-owned apps
For use cases such as analytics or fraud prevention on a given device, you might need to correlate usage or actions across a set of apps owned by your organization. Google Play services offers a privacy-friendly option called app set ID.
App set ID scope
The app set ID can have one of the following defined scopes. To determine which scope a particular ID is associated with, call getScope().
Caution: When Google Play services updates from a version that only supports app scope to a version that supports developer scope, the app set ID's value is reset automatically, without any developer action. See other reasons developers shouldn't rely on a cached value of the app set ID.
Google Play developer scope
Note: The app set SDK attempts to return app set IDs that have the developer scope without any additional developer action, unless the app satisfies the conditions for app scope, described in the App scope section.
For apps that are installed by the Google Play store, the app set ID API returns an ID scoped to the set of apps published under the same Google Play developer account.
For example, suppose you publish two apps under your Google Play developer account and both apps are installed on the same device through the Google Play store. The apps share the same app set ID on that device. The ID is the same even if the apps are signed by different keys.
App scope
Under any of the following conditions, the app set ID SDK returns an ID unique to the calling app itself on a given device:
The app is installed by an installer other than the Google Play store.
Google Play services is unable to determine an app's Google Play developer account.
The app is installed on a device without Google Play services.
Don't rely on a cached value of app set ID
Under any of the following conditions, the app set ID for a given set of Google Play store-installed apps on a device can be reset:
The app set ID API hasn't been accessed by the groups of apps that share the same ID value for over 13 months.
The last app from a given set of apps is uninstalled from the device.
The user performs a factory reset of the device.
Your app must use the SDK to retrieve the ID value every time it's needed.
Add the app set ID SDK to your app
The following snippet shows an example build.gradle file that uses the app set ID library:
dependencies {
implementation 'com.google.android.gms:play-services-appset:16.1.0'
}
The following sample snippet demonstrates how you can retrieve the app set ID asynchronously using the Tasks API in Google Play services:
Kotlin
Java
More
val client = AppSet.getClient(applicationContext) as AppSetIdClient
val task: Task<AppSetIdInfo> = client.appSetIdInfo as Task<AppSetIdInfo>
task.addOnSuccessListener({
// Determine current scope of app set ID.
val scope: Int = it.scope
// Read app set ID value, which uses version 4 of the
// universally unique identifier (UUID) format.
val id: String = it.id
})
For more information about the UUID format, see Universally unique identifier.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2026-10-08 UTC.
X
Follow @AndroidDev on X
YouTube
Check out Android Developers on YouTube
LinkedIn
Connect with the Android Developers community on LinkedIn
MORE ANDROID
Android
Android for Enterprise
Security
Source
News
Blog
Podcasts
DISCOVER
Gaming
Machine Learning
Health & Fitness
Camera & Media
Privacy
5G
ANDROID DEVICES
Large screens
Wear OS
ChromeOS devices
Android for cars
Android TV
RELEASES
Android 17
Android 16
Android 15
Android 14
Android 13
Android 12
Android 11
DOCUMENTATION AND DOWNLOADS
Android Studio guide
Developers guides
API reference
Download Studio
Android NDK
SUPPORT
Report platform bug
Report documentation bug
Google Play support
Join research studies
Android
Chrome
Firebase
Google Cloud Platform
All products
Privacy
License
Brand guidelines
Get news and tips by email
Subscribe