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;
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.
Comments
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
Comments
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.
Comments
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();