2

I need an ID which will not change for android device and it should be unique at any time even if WIFI, SIM, Bluetooth are not present as well as when user reset his/her phone or flash with new OS.

I know about these Id. IMEI : It is not available for all device(Ex. SIM less device).

MAC : Is is not available for all device(Ex. WIFI less device).

Android Id : It changed when user Reset his/her phone or device is root with new OS.

Which will be better for my requirement?

Should I used Serial Id. Build.SERIAL??

Rahul Giradkar
  • 1,818
  • 1
  • 17
  • 28
  • If this is related with a server it could be an e-mail, or a generated ID which will be sent to the server and it will be unique – Antonios Tsimourtos Aug 26 '16 at 11:32
  • Yes it is related to server.but I need unique device Id which will identify the device not a user. – Rahul Giradkar Aug 26 '16 at 11:38
  • 1
    Why would you need a unique ID on a device that cannot connect to the internet? – Abbas Aug 26 '16 at 11:38
  • 1
    Sumbled upon this. Possible duplicate. http://stackoverflow.com/questions/2785485/is-there-a-unique-android-device-id – Ramesh Aug 26 '16 at 11:53
  • @Abbas I need to identify the device. Even if user reinstall the app or he install app with new email Id on same device. I have to recognize device not a user. – Rahul Giradkar Aug 26 '16 at 12:19
  • @RahulGiradkar Yes I get that but I was just asking what's the point of generating an ID for a device that doesn't have Internet accessibility since you won't be able to connect it to the server. – Abbas Aug 26 '16 at 12:21
  • @Abbas Yes it is connected to internet connected to Internet. – Rahul Giradkar Aug 26 '16 at 12:25

2 Answers2

2

You could use a combination of manufacturer info, device name and serial. This should be unique and available over all devices:

StringBuilder sb = new StringBuilder();

sb.append(android.os.Build.MANUFACTURER);
sb.append(" ");
sb.append(android.os.Build.MODEL);
sb.append(" ");
sb.append(android.os.Build.SERIAL);

String unique = sb.toString();
devnull69
  • 16,402
  • 8
  • 50
  • 61
1

Please check this link below right from android developers blog. http://android-developers.blogspot.in/2011/03/identifying-app-installations.html

Copying specific details from the link to answer your question.

For the vast majority of applications, the requirement is to identify a particular installation, not a physical device. Fortunately, doing so is straightforward.

There are many good reasons for avoiding the attempt to identify a particular device. For those who want to try, the best approach is probably the use of ANDROID_ID on anything reasonably modern, with some fallback heuristics for legacy devices.

If your requirement is to uniquely identify each user generating UUID for each user and storing it on server would do. But if you really want to get physical device unique identifier, ANDORID_ID looks to be the only probable way.

Having said that, Please be aware of this bug (and how android_id is different for different profiles on same device).

http://code.google.com/p/android/issues/detail?id=42523

Hope this helps.

Ramesh
  • 1,287
  • 1
  • 9
  • 14