0

I'm developing an android application using eclipse. I need to get the unique device ID of the users so that they can provide their opinions on the app, but I don't know how... I'd really appreciate if anyone could tell me how to get android device IDs!

  • [This has been discussed extensively](http://stackoverflow.com/questions/2785485/is-there-a-unique-android-device-id). – tilpner Dec 26 '13 at 15:18

3 Answers3

0

Look at the constant ANDROID_ID in android.provider.Secure.Settings.

http://developer.android.com/reference/android/provider/Settings.Secure.html#ANDROID_ID

There are three types of identifier on android phone.

  1. IMEI

  2. IMSI

    String ts = Context.TELEPHONY_SERVICE; TelephonyManager mTelephonyMgr = (TelephonyManager) getSystemService(ts); String imsi = mTelephonyMgr.getSubscriberId(); String imei = mTelephonyMgr.getDeviceId();

  3. Android ID It is a 64-bit hex string which is generated on the device's first boot. Generally it won't be changed unless is factory reset.

    Secure.getString(getContentResolver(), Secure.ANDROID_ID);

Imran Ali Khan
  • 8,469
  • 16
  • 52
  • 77
0

Use following line,

import android.provider.Settings.Secure;

String android_id = Secure.getString(this.getContentResolver(), Secure.ANDROID_ID);
Kirk
  • 4,957
  • 2
  • 32
  • 59
0

Try this code:

 Will return the MDN or MEID of the device depending on which radio the
 phone uses (GSM or CDMA). Each device MUST return a unique value here
 (assuming it's a phone). This should work for any Android device with a
  sim slot or CDMA radio. Requires READ_PHONE_STATE permission

public static String getDeviceUID(Context context) {
    TelephonyManager tManager = (TelephonyManager) context
            .getSystemService(Context.TELEPHONY_SERVICE);
    return tManager.getDeviceId();
}


  The Android ID (a unique 64-bit value) as a hex string. Identical to that
  obtained by calling GoogleLoginService.getAndroidId(); it is also placed
  here so you can get it without binding to a service.

public static String getAndroidID(Context context) {
    return Settings.System.getString(context.getContentResolver(),
            Settings.Secure.ANDROID_ID);
}
rupesh
  • 2,865
  • 4
  • 24
  • 50