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

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

    to get IMEI (international mobile equipment identifier)

    public String getIMEI(Activity activity) {
        TelephonyManager telephonyManager = (TelephonyManager) activity
                .getSystemService(Context.TELEPHONY_SERVICE);
        return telephonyManager.getDeviceId();
    }
    

    to get device unique id

    public String getDeviceUniqueID(Activity activity){
        String device_unique_id = Secure.getString(activity.getContentResolver(),
                Secure.ANDROID_ID);
        return device_unique_id;
    }
    

提交回复
热议问题