Right now my algorithm based only on IMEI. And here is the problem: some devices doesn't have radio module, so they also doesn't have IMEI I need unique parameters ( CPU ID, flash ID, MAC etc) to generate ID without using IMEI. And how to get them with Java. Preferably without Root Thank you
5 Answers
Use Build.SERIAL
to get the unique serial number of an android device. This will return a string value. In emulator this code may return the string "unknown". But try it with a device. It really works... :)
String id=Build.SERIAL;

- 1,884
- 14
- 30
-
this method will not work on API level less than 9(Android 2.2.3) – edwin Jan 18 '13 at 06:09
-
This serial never changes? Even after factory reset or update OS? Its unique for each device? – yuralife May 23 '13 at 08:17
ANDROID_ID
More specifically, Settings.Secure.ANDROID_ID. This is a 64-bit quantity that is generated and stored when the device first boots. It is reset when the device is wiped.
ANDROID_ID seems a good choice for a unique device identifier. There are downsides: First, it is not 100% reliable on releases of Android prior to 2.2 (“Froyo”). Also, there has been at least one widely-observed bug in a popular handset from a major manufacturer, where every instance has the same ANDROID_ID.

- 20,500
- 38
- 146
- 211
You may use android.os.Build.getSerial()
instead of android.os.Build.SERIAL
android.os.Build.SERIAL
--> This field was deprecated in API level O. Use getSerial() instead. Source: https://developer.android.com/reference/android/os/Build.html

- 1,851
- 22
- 18
You can use the Setting.secure which is inbuilt to get the device id. this device ID is fixed till you reset the factory setting.
Settings.Secure.getString(getContentResolver(),Settings.Secure.ANDROID_ID);
This is the unique Id of your device which is stable till you reset to the factory setting.

- 1,561
- 13
- 23
below code can help you to get your device id
String ts = Context.TELEPHONY_SERVICE;
TelephonyManager mTelephonyMgr = (TelephonyManager) getSystemService(ts);
String imsi = mTelephonyMgr.getSubscriberId();
String imei = mTelephonyMgr.getDeviceId();

- 2,436
- 2
- 17
- 24
-
My device doesn't have radio module, so getSubscriberId() and getDeviceId() returns NULL – duck_ok Oct 03 '12 at 12:20