-
Notifications
You must be signed in to change notification settings - Fork 1
Is there a unique Android device ID?
Google recommends against a unique device identifier and pro an application installation identifier - giving a skeletal implementation of such an identifier. For a hardware identifier most people would use the value returned by String getDeviceId(), which (depending on the network technology) is the IMEI, MEID, or ESN of the phone (the IMEI for GSM and the MEID or ESN for CDMA phones) which is unique to that piece of hardware. But :
- Wifi-only devices, music players or tablets that don’t have telephony hardware just don’t have this kind of unique identifier.
- On devices which do have this, it persists across device data wipes and factory resets. It’s not clear at all if, in this situation, your app should regard this as the same device. Moreover it can easily result in privacy holes (user wipes their device and passes it on to another person)
- It requires READ_PHONE_STATE permission, which is irritating if you don’t otherwise use or need telephony - and it is a "scary" permission to require from the user
- There are a few instances of production phones for which the implementation is buggy and returns garbage, for example zeros or asterisks
The points above are addressed by Settings.Secure.ANDROID_ID - A 64-bit number (as a hex string) that is randomly generated on the device's first boot and should remain constant for the lifetime of the device - or till a factory reset is performed on the device. Unfortunately there are issues here as well :
- A well known bug for Froyo (and maybe Eclair) whereupon different devices will return the same ID : 9774d56d682e549c . See here and here
- Since support was added for multiple user profiles on a single device each profile is reported to have its own ANDROID_ID - moreover the docs are wrong on this
- It is not 100% reliable on releases of Android prior to 2.2 (“Froyo”) (see the blog at Android developers)
Other options include the wifi and bluetooth mac addresses - if available - and the SIM card (if present, unique etc) but no airtight solution yet.
Discussions:
http://www.pocketmagic.net/2011/02/android-unique-device-id/
http://stackoverflow.com/questions/2322234/how-to-find-serial-number-of-android-device
http://stackoverflow.com/questions/2785485/is-there-a-unique-android-device-id
http://stackoverflow.com/questions/13744565/android-device-id-confusion/13831099#13831099