getDeviceId()
Returns the unique identifier of the device to subscribe, for example, IMEI for GSM and MEID for CDMA phones. Return null if the device identifier is unavailable.
This method was deprecated at API level 26.
Use (@link getImei} , which returns IMEI for GSM
or (@link getMeid} , which returns the MEID for CDMA .
for more information read TelephonyManager
Try to do IMEI
@RequiresApi(api = Build.VERSION_CODES.O) TelephonyManager tm = (TelephonyManager) getSystemService(this.TELEPHONY_SERVICE); String imei = tm.getImei();
OR
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { String imei = telephonyMgr.getImei(); } else { String imei = telephonyMgr.getDeviceId(); }
Try this to get MEID
@RequiresApi(api = Build.VERSION_CODES.O) TelephonyManager tm = (TelephonyManager) getSystemService(this.TELEPHONY_SERVICE); String meid=tm.getMeid();
OR
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { String meid=tm.getMeid(); }
source share