2

I want to generate Uuid for my app so I tried many methods for this.

1) Getting Serial number of device using android.os.Build.SERIAL(this returns "unknown" as result)

2) Dealing with device id (I don't know what it will return in case of tablet devices)

3) Getting Android id using android.provider.Settings.Secure.ANDROID_ID(seems some problem with android 2.2 version)

4) Generating Uuid using java.util.UUID

5) Generating pseudo Uuid using android.os.Build properties

All these methods shows some problems. So I am confused which to be choose? Can anybody suggest me best method?

Android Developer Blog says android id will be unique

Also I heard Android id of device can be changed on factory resetting or os updations .

So is there any chance of for duplication new android id generated during factory resetting or os updations ?

NB:Suppose A Condition

My question is what will happened same 2 device Model of same manufacture will under go restore or os updations.the Android id will change. I am asking about this new id. Will there any chance for android id be same in both device?

CRABOLO
  • 8,605
  • 39
  • 41
  • 68
edwin
  • 7,985
  • 10
  • 51
  • 82

3 Answers3

1

Yes, there is a chance of duplicate ID's, but it's negligible.

There's 2^64 possible values for ANDROID_ID, and they are generated with some random function. But it is very very very unlikely that you will ever see a duplicate value - search for discussions about GUID uniqueness to get the point.

In short: you can assume that ANDROID_ID is unique.

1615903
  • 32,635
  • 12
  • 70
  • 99
  • is ANDROID_ID available for all android device including tablets and CDMA devices (i know it generates from first time booting of the os so ANDROID_ID will be there .still i just want to assure this. i had checked with 2-3 phone devices unfortunately i didn't got chance to test with tablets) – edwin Dec 19 '12 at 10:08
1

The ANDROID_ID is generated each time you initialize the device (after reset, etc.). It doesn't depend on model, serial no., etc. Even if you have two identical devices, their ANDROID_ID's after reset should be different. The ID is not particular special, except that it is global for the device. You can achieve the same thing with an UUID for your app.

Nikolay Elenkov
  • 52,576
  • 10
  • 84
  • 84
  • i know it is generated during first time initialize of device . i just want to know is it same for all devices other than telephone and CDMA(it works like a radio . i was not able to test with bot these devices) – edwin Dec 19 '12 at 10:18
  • 1
    It doesn't depend on the device model or radio functionality. However, some early phones (by Motorola, IIRC) have the same ID and some return `null`. Those should be mostly updated now, but you might want to handle it just in case. Or just use your own UUID. What is your ultimate purpose and why do you want to use the ANDROID_ID? – Nikolay Elenkov Dec 19 '12 at 10:39
  • Note to editors: please don't introduce additional typos :) Or change the meaning of sentences. – Nikolay Elenkov Dec 19 '12 at 10:42
0

Creating unique id's for android device has been discussed vivdly in this link In short use this.

import android.provider.Settings.Secure;

private String android_id = Secure.getString(getContext().getContentResolver(),
                                                        Secure.ANDROID_ID);
Community
  • 1
  • 1
san
  • 1,845
  • 13
  • 23
  • i know to create Android id . my question is what will happened same 2 device Model of same manufacture will under go restore or os updations.the Android id will change . i am asking about this new id . will there any chance for android id be same in both device? – edwin Dec 19 '12 at 08:26