java 为什么不推荐“使用 getString() 获取设备标识符”?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/47691310/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Why is "using getString() to get device identifiers" not recommended?
提问by Ege Kuzubasioglu
I'm trying to get my device ID to Logcat but Android Studio is giving me this warning.
我正在尝试将我的设备 ID 获取到 Logcat,但 Android Studio 给了我这个警告。
using getstring to get device identifiers is not recommended
不推荐使用 getstring 来获取设备标识符
String deviceID = Settings.Secure.getString(getApplicationContext().getContentResolver(),
Settings.Secure.ANDROID_ID);
Why is it not recommended?
为什么不推荐?
采纳答案by Giovanni
The full warning says:
完整的警告说:
Using these device identifiers is not recommended other than for high value fraud prevention and advanced telephony use-cases. For advertising use-cases, use AdvertisingIdClient$Info#getId and for analytics, use InstanceId#getId.
More info: https://developer.android.com/training/articles/user-data-ids.html
除了用于高价值欺诈预防和高级电话用例之外,不建议使用这些设备标识符。对于广告用例,请使用 AdvertisingIdClient$Info#getId,对于分析,请使用 InstanceId#getId。
更多信息:https: //developer.android.com/training/articles/user-data-ids.html
I think Android does not recommend using this value, since it's a permanent unique id, which can be used to track your user, and he or she can't change this id or prevent you to read it. The other options given in the warning respects your user's wishes. That's why Android recommend you to use that.
我认为 Android 不建议使用此值,因为它是一个永久唯一 id,可用于跟踪您的用户,他或她无法更改此 id 或阻止您阅读它。警告中给出的其他选项尊重用户的意愿。这就是 Android 建议您使用它的原因。
It really depends on what you are going to do with that id. Privacy is a sensitive thing these days.
这真的取决于你打算用那个 id 做什么。如今,隐私是一件敏感的事情。
Also check this:
还要检查这个:
...you must abide by a user's ‘Opt out of interest-based advertising' or 'Opt out of Ads Personalization' setting. If a user has enabled this setting, you may not use the advertising identifier for creating user profiles for advertising purposes or for targeting users with personalized advertising. Allowed activities include contextual advertising, frequency capping, conversion tracking, reporting and security and fraud detection.
...您必须遵守用户的“选择退出基于兴趣的广告”或“退出个性化广告”设置。如果用户已启用此设置,则您不得将广告标识符用于创建用于广告目的的用户配置文件或通过个性化广告定位用户。允许的活动包括上下文广告、频次上限、转换跟踪、报告以及安全和欺诈检测。
Source: https://developer.android.com/training/articles/user-data-ids.html
来源:https: //developer.android.com/training/articles/user-data-ids.html