How to get the device's IMEI/ESN programmatically in android?

后端 未结 20 2587
滥情空心
滥情空心 2020-11-22 05:19

To identify each devices uniquely I would like to use the IMEI (or ESN number for CDMA devices). How to access this programmatically?

20条回答
  •  眼角桃花
    2020-11-22 05:49

    In addition to the answer of Trevor Johns, you can use this as follows:

    TelephonyManager telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
    telephonyManager.getDeviceId();
    

    And you should add the following permission into your Manifest.xml file:

    
    

    In emulator, you'll probably get a like a "00000..." value. getDeviceId() returns NULL if device ID is not available.

提交回复
热议问题