I am getting the IMEI ID null from the telephonymanager. What to do?
is there any workaround for that?
Finding your IMEI number on your Android device Here's how to find your IMEI number in the settings on your Android device: Go to the Settings app. Scroll down and select About Phone. Scroll down to find your IMEI number.
To view the IMEI number under Settings Find and tap Settings. Android 10 / 11 / 12: About phone → IMEI. Android 9: System → About phone → IMEI.
The android device ID is a unique alphanumeric code generated for your Android phone when you first set it up. This code basically identifies your device similar to how the IMEI number works. However, Android device ID is specifically used for identification purposes, instead of tracking your device.
To get IMEI (international mobile equipment identifier) and if It is above API level 26 then we get telephonyManager. getImei() as null so for that, we use ANDROID_ID as a Unique Identifier.
Android Q has restricted to access for both IMEI and serial no. It is available only for platform and apps with special carrier permission. Also the permission READ_PRIVILEGED_PHONE_STATE is not available for non platform apps.
If you try to access it throws below exception
java.lang.SecurityException: getImeiForSlot: The user 10180 does not meet the requirements to access device identifiers.
Please refer documentation: https://developer.android.com/preview/privacy/data-identifiers#device-ids
Also refer Issue
I am late to post answer. I still believe my answer will help someone. Android 10 Restricted developer to Access IMEI number.
You can have a alternate solution by get Software ID. You can use software id as a unique id. Please find below code as i use in Application.
public static String getDeviceId(Context context) { String deviceId; if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { deviceId = Settings.Secure.getString( context.getContentResolver(), Settings.Secure.ANDROID_ID); } else { final TelephonyManager mTelephony = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); if (mTelephony.getDeviceId() != null) { deviceId = mTelephony.getDeviceId(); } else { deviceId = Settings.Secure.getString( context.getContentResolver(), Settings.Secure.ANDROID_ID); } } return deviceId; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With