简体   繁体   English

获取安卓设备的永久唯一 ID

[英]Get Permanent Unique ID for android device

I have an application in which I want to identify the device with Unique ID,我有一个应用程序,我想在其中识别具有唯一 ID 的设备,

I have tried multiple solutions but doing after phone reset unique ID gets changed(like ANDROID_ID)我尝试了多种解决方案,但在电话重置后唯一 ID 被更改(如 ANDROID_ID)

I have used below StackOverflow links which are not usable now.我使用了以下 StackOverflow 链接,这些链接现在无法使用。

Is there a unique Android device ID? 是否有唯一的 Android 设备 ID? , ,

How to get unique device numer in Android? 如何在Android中获得唯一的设备编号? , ,

Get Unique ID of Android Device? 获取 Android 设备的唯一 ID? , ,

How to get unique device hardware id in Android? 如何在 Android 中获取唯一的设备硬件 ID? , ,

Get unique device ID in android 在android中获取唯一的设备ID

Android Q has restricted access for IMEI and serial number. Android Q 限制了对 IMEI 和序列号的访问。 It is available only for platforms and apps with special carrier permission.它仅适用于具有特殊运营商许可的平台和应用程序。 Also, permission READ_PRIVILEGED_PHONE_STATE is not available for non-platform apps.此外,权限 READ_PRIVILEGED_PHONE_STATE 不适用于非平台应用程序。

Many people may mark this as duplicate but please note that I am looking for a unique id that will last for a device.许多人可能会将其标记为重复,但请注意,我正在寻找一个可以持续用于设备的唯一 ID。 (which will not change even after resetting/formating the device) (即使在重置/格式化设备后也不会改变)

It's not possible in latest Android versions by design to prevent apps from tracking devices due to privacy reasons.由于隐私原因,在最新的 Android 版本中无法阻止应用程序跟踪设备。 Especially if you want to track after a device factory reset as mentioned.特别是如果您想在提到的设备恢复出厂设置后进行跟踪。

See Best Practices Guide请参阅 最佳实践指南

Recommendation is to use Advertising ID and not associate it with any hardware identifiers.建议使用广告 ID,不要将其与任何硬件标识符相关联。 You may identify the user account, but not the device itself.您可以识别用户帐户,但不能识别设备本身。 This allows the user to change the user account if they deem necessary or uninstall/reinstall the app at worst.这允许用户在他们认为必要时更改用户帐户,或者在最坏的情况下卸载/重新安装应用程序。

Play Store policy notes Play 商店政策说明

Association with personally-identifiable information or other identifiers.与个人身份信息或其他标识符的关联。 The advertising identifier must not be connected to personally-identifiable information or associated with any persistent device identifier (for example: SSID, MAC address, IMEI, etc.) without explicit consent of the user.未经用户明确同意,广告标识符不得与个人身份信息相关联或与任何永久性设备标识符(例如:SSID、MAC 地址、IMEI 等)相关联。

Now, you may track a device as long as现在,您可以跟踪设备,只要

  1. you don't distribute your app via the play store (ie sideloading, but you do risk getting booted if Play Protect on device may notice you. I can't remember the default setting, but if the device has play services, it may scan sideloaded apps and remove them if it finds malicious behavior.)通过 Play 商店分发您的应用程序(即旁加载,但如果设备上的Play Protect可能注意到您,您确实有被启动的风险。我不记得默认设置,但如果设备有播放服务,它可能会扫描旁加载的应用程序并在发现恶意行为时将其删除。)
  2. Use hardware identifiers on older versions of Android, (still subject to Play Protect, and also Play Store if you distribute through there) or force users to use a custom ROM在旧版本的 Android 上使用硬件标识符(仍然受 Play Protect 的约束,如果您通过那里分发,也受 Play Store 约束)或强制用户使用自定义 ROM

read https://support.google.com/googleplay/android-developer/answer/6048248?hl=en 阅读https://support.google.com/googleplay/android-developer/answer/6048248?hl=zh_CN

The Google Play Developer Program Policy requires that all updates and new apps uploaded to Google Play use the advertising ID (when available on a device) in place of any other device identifiers for any advertising purposes. Google Play开发者计划政策要求所有上传到Google Play的更新和新应用都必须使用广告ID(在设备上可用)代替任何其他设备标识符,以用于任何广告目的。 You're responsible for ensuring your apps are in compliance with policies regarding its usage, as well as all Play policies. 您有责任确保您的应用遵守有关其使用情况的政策以及所有Play政策。

Apps using a persistent ID other than the advertising ID may receive a policy violation warning via the publisher site or the email address used to register the account. 使用非广告ID的永久ID的应用可能会通过发布者网站或用于注册帐户的电子邮件地址收到违反政策的警告。 If you receive a warning, you should ensure that any published APKs comply with the advertising ID related guidance in the Developer Program Policy. 如果收到警告,则应确保任何已发布的APK都符合开发人员计划政策中与广告ID相关的指南。 If you are using a third-party ad SDK, please contact the SDK maker to obtain a new version that complies with this new policy. 如果您使用的是第三方广告SDK,请与SDK制造商联系,以获取符合此新政策的新版本。

and https://developers.google.com/android/reference/com/google/android/gms/ads/identifier/AdvertisingIdClient https://developers.google.com/android/reference/com/google/android/gms/ads/identifier/AdvertisingIdClient

Helper library for retrieval of advertising ID and related information such as the limit ad tracking setting. 辅助程序库,用于检索广告ID和相关信息,例如限制广告跟踪设置。

It is intended that the advertising ID completely replace existing usage of other identifiers for ads purposes (such as use of ANDROID_ID in Settings.Secure) when Google Play Services is available. 当Google Play服务可用时,广告ID旨在完全替代出于广告目的而使用的其他其他标识符(例如,在Settings.Secure中使用ANDROID_ID)。 Cases where Google Play Services is unavailable are indicated by a GooglePlayServicesNotAvailableException being thrown by getAdvertisingIdInfo(). 由getAdvertisingIdInfo()引发的GooglePlayServicesNotAvailableException指示了Google Play服务不可用的情况。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM