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;
    }
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章