Why is "using getString() to get device identifiers" not recommended?
I'm trying to get my device ID to Logcat but Android Studio is giving me this warning.
using getstring to get device identifiers is not recommended
String deviceID = Settings.Secure.getString(getApplicationContext().getContentResolver(),
Settings.Secure.ANDROID_ID);
Why is it not recommended?
Solution 1:
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
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.
It really depends on what you are going to do with that id. Privacy is a sensitive thing these days.
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