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

后端 未结 20 2641
滥情空心
滥情空心 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:42

    From: http://mytechead.wordpress.com/2011/08/28/how-to-get-imei-number-of-android-device/:

    The following code helps in obtaining IMEI number of android devices :

    TelephonyManager tm = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
    String device_id = tm.getDeviceId();
    

    Permissions required in Android Manifest:

    android.permission.READ_PHONE_STATE
    

    NOTE: In case of tablets or devices which can’t act as Mobile Phone IMEI will be null.

提交回复
热议问题