Is Secure.ANDROID_ID unique for each device?
I am using this call:
To get a UID for the device. I think I am getting the same ID from multiple devices though. Should this be possible?
The ID in question is: 9774d56d682e549c and apparently there is an issue with several devices returning this ID http://code.google.com/p/android/issues/list?cursor=10603&updated=10603&ts=1295993403
5 Solutions collect form web for “Is Secure.ANDROID_ID unique for each device?”
Check into this thread,. However you should be careful as it’s documented as “can change upon factory reset”. Use at your own risk, and it can be easily changed on a rooted phone. Also it appears as if some manufacturers have had issues with their phones having duplicate numbers thread. Depending on what your trying to do, I probably wouldnt use this as a UID.
So if you want something unique to the device itself,
TM.getDeviceId() should be sufficient.
Here is the code which shows how to get Telephony manager ID. The android Device ID that you are using can change on factory settings and also some manufacturers have issue in giving unique id.
TelephonyManager tm = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE); Log.d("ID", "Android ID: " + Secure.getString(getContentResolver(), Secure.ANDROID_ID)); Log.d("ID", "Device ID : " + tm.getDeviceId());
Be sure to take permissions for
TelephonyManager by using
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
With Android O the behaviour of the ANDROID_ID will change. The ANDROID_ID will be different per app per user on the phone.
In O, Android ID (Settings.Secure.ANDROID_ID or SSAID) has a different value for each app and each user on the device. Developers requiring a device-scoped identifier, should instead use a resettable identifier, such as Advertising ID, giving users more control. Advertising ID also provides a user-facing setting to limit ad tracking.
Additionally in Android O:
- The ANDROID_ID value won’t change on package uninstall/reinstall, as
long as the package name and signing key are the same. Apps can rely
on this value to maintain state across reinstalls.
- If an app was installed on a device running an earlier version of
Android, the Android ID remains the same when the device is
updated to Android O, unless the app is uninstalled and
- The Android ID value only changes if the device is factory
reset or if the signing key rotates between uninstall and
- This change is only required for device manufacturers
shipping with Google Play services and Advertising ID. Other
device manufacturers may provide an alternative resettable
ID or continue to provide ANDROID ID.
I’ve read a few things about this and unfortunately the ANDROID_ID should not be relied on for uniquely identifying an individual device.
It doesn’t seem to be enforced in Android compliance requirements and so manufacturers seem to implement it the way they choose including some using it more as a ‘model’ ID etc.
Also, be aware that even if a manufacturer has written a generator to make it a UUID (for example), it’s not guaranteed to survive a factory reset.
Just list an alternaitve solution here, the Advertising ID:
Copied from the link above:
The advertising ID is a unique, user-resettable ID for advertising, provided by Google Play services. It gives users better controls and provides developers with a simple, standard system to continue to monetize their apps. It enables users to reset their identifier or opt out of personalized ads (formerly known as interest-based ads) within Google Play apps.
The limitations are:
- Google Play enabled devices only.