6

I am developing an android application in which I want to get UDID of android emulator. How can i do it?

Thanks in advance, Tushar

Vladimir Ivanov
  • 42,730
  • 18
  • 77
  • 103
Tushar
  • 5,907
  • 15
  • 49
  • 81

3 Answers3

9

I'm not sure if this is what you're after but you could use: Settings.Secure.ANDROID_ID

public class YourActivity extends Activity {
    //...Omitted code
    public String getId() {
        String id = android.provider.Settings.System.getString(super.getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);
        return id;
    }
}

Note that this isn't an IMEI number, if you need this use getDeviceId()

firefox1986
  • 1,602
  • 11
  • 9
4

You can do this using the TelephonyManager and the method getDeviceID(). But unfortunately I think for Emulator it will always return null.

Context.getSystemService(Context.TELEPHONY_SERVICE).getDeviceID();

Don't forget to set the permission that is required for that:

Returns the unique device ID, for example, the IMEI for GSM and the MEID or ESN for CDMA phones. Return null if device ID is not available. Requires Permission: READ_PHONE_STATE

If you want a unique ID as a hex String you might also be interested in:

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

RoflcoptrException
  • 51,941
  • 35
  • 152
  • 200
  • I updated the answer so that you can see how to use getDeviceID – RoflcoptrException Mar 25 '11 at 08:52
  • Android Device does not have a UUID. Instead it has an IMEI Number and SIM Serial for GSM mobiles. For CDMA phones it is MEID or ESN. All these IDs are unique. For getting the SIM Serail number use this. May Help you, `tmgr.getSimSerialNumber();`. All these methods will return result as string. – Anoop Chandrika HarisudhanNair Mar 25 '11 at 13:28
  • getDeviceId(): This method was deprecated in API level 26 (Android 8). – testing Feb 15 '19 at 08:35
-1

Have you tried Ti.Platform.id ? That returns a value for me in the emulator.

jzd
  • 23,473
  • 9
  • 54
  • 76