2

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

Azhar
  • 20,500
  • 38
  • 146
  • 211
duck_ok
  • 61
  • 1
  • 5

5 Answers5

3

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;
Anu
  • 1,884
  • 14
  • 30
2

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.

This could help you

Azhar
  • 20,500
  • 38
  • 146
  • 211
1

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

Dhananjay M
  • 1,851
  • 22
  • 18
0

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.

Arpit Patel
  • 1,561
  • 13
  • 23
-2

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();
Hardik Nadiyapara
  • 2,436
  • 2
  • 17
  • 24