How can we validate IMEI Number after Android version 10?

1.1k Views Asked by At

I need to validate IMEI number, is their any mechanism for validating the input IMEI? Can we get status of validation in true or false ?

2

There are 2 best solutions below

0
Sidharth Mudgil On

You cannot, Third-party apps can not use IMEI nor the serial number of a phone and other non-resettable device identifiers.

Restriction on non-resettable device identifiers

Starting in Android10, apps must have the READ_PRIVILEGED_PHONE_STATE privileged permission in order to access the device's non-resettable identifiers, which include both IMEI and serial number. read more

You can still get the non-resettable device identifiers in older android versions by calling android.telephony.TelephonyManager.getDeviceId().

Alternatively, If you can get a unique id use this code

Secure.getString(getContext().getContentResolver(),Secure.ANDROID_ID);
1
Islam Alshnawey On

No, you cannot get IMEI after Android 10, Use This Approach will do the same purpose, but beware it's not the same for debugging and release also it contains both Numbers and Letters.

 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
     imei = Settings.Secure.getString(Objects.requireNonNull(getContext()).getContentResolver(), Settings.Secure.ANDROID_ID);
    }