0

Possible Duplicate:
Unique ID of Android device

AFAIK, the emei number, mac address can be change by some hacking work. I am in need to find an unique value on each device which can not replace, cannot edit. Is there any value?

Community
  • 1
  • 1
Nguyen Minh Binh
  • 23,891
  • 30
  • 115
  • 165
  • 2
    No downvote. Please search before posting new questions; http://stackoverflow.com/questions/4468248/unique-id-of-android-device – Mudassir Oct 30 '12 at 12:42
  • 1
    Hi, I am asking about unique value on various devices. Not android only. Please reopen my question for more discussion. Thanks. – Nguyen Minh Binh Oct 31 '12 at 02:23
  • I am thinking about GUID. We can generate a GUID number then save it at an encrypt file. Do you think this's good? – Nguyen Minh Binh Oct 31 '12 at 14:18

3 Answers3

0

Try this.

String android_id = Secure.getString(getContentResolver(), Secure.ANDROID_ID);

NOTE: The emulator will return a NULL value so if you try to use this value in the emulator environment your application will crash.

Chirag
  • 56,621
  • 29
  • 151
  • 198
  • 1
    This is actually documented as potentially changing on a factory reset. And actually, can be changed at will with a custom ROM set up to do so. http://developer.android.com/reference/android/provider/Settings.Secure.html#ANDROID_ID – Richard Taylor Oct 30 '12 at 14:32
0

For Mac OSX you can use the command line:

ioreg -rd1 -c IOPlatformExpertDevice | awk '/IOPlatformUUID/ { split($0, line, "\""); printf("%s\n", line[4]); }'

usain
  • 746
  • 5
  • 16
0

For phones or devices that carry a sim card, you can rely on the ICCID which is basically the serial number of the SIM. I have unheard of ways to hack the ICCID, so you can probably trust it.

Android allows you to fectch the ICCID through: http://developer.android.com/reference/android/telephony/TelephonyManager.html#getSimSerialNumber%28%29

Another option is the IMSI (corresponds to the subscription number), also available on android.

Thomas
  • 2,751
  • 5
  • 31
  • 52
  • So, the ICCID may change when user insert another simcard. I mean, this not a unique value of device. It's a unique value of Sim card. – Nguyen Minh Binh Oct 31 '12 at 02:14
  • Yes. The issue is that an unique value of the device would consist of its serial number. However, there seems not to be much support to retrieve that from PCs. On phones, the only thing you have is the IMEI, which as you mentioned can be hacked and reprogrammed. In that point, the ICCID, has an advantage as it "cant" be reprogrammed. I guess for your this case there is no perfect solution and you will need to do a compromise in one side or the other – Thomas Oct 31 '12 at 08:17
  • on PC I know that we can get mac address. It's a unique value (if it isn't hacked) – Nguyen Minh Binh Oct 31 '12 at 09:31
  • Yeah, but mac is not a very "reliable" as it can be hacked, desktops can have theirs network card changed and pcs may have more than one network card =D I guess it all boils down to the underlying requirements behind you need for uniqueness – Thomas Oct 31 '12 at 09:40