Getting Udid in android

前端 未结 3 1049
醉话见心
醉话见心 2020-12-16 05:06

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

3条回答
  •  清歌不尽
    2020-12-16 06:00

    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

提交回复
热议问题