Android 10 获取不了IMEI解决

 /**
     * 获取手机IMEI号((International Mobile Equipment Identity,国际移动身份识别码)
     */
    public static String getIMEI(Context context) {
        TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(context.TELEPHONY_SERVICE);
        String deviceId = telephonyManager.getDeviceId();
        //android 10以上已经获取不了imei了 用 android id代替
     if(TextUtils.isEmpty(deviceId)){
         deviceId = Settings.System.getString(
                 context.getContentResolver(), Settings.Secure.ANDROID_ID);
     }
     return  deviceId;
    }

你可能感兴趣的:(andriod)