TelephonyManager returns null for IMEI number: what can cause this?

I am working on an Android application and getting null back for IMEI number when using TelophonyManager . This happens on several Huawei phones. (All of them are Ascend Y530).

All phones have SIM cards, and they seem to be working fine. I got the impression that only a broken phone will return null IMEI. Clearly, this is not so.

Questions. What is this IMEI number - where is it stored on the device? And what does it mean when a seemingly beautiful phone returns its value as null ?

EDIT

It should be noted that the IMEI number is not always null . About one and a half times, this seems valid (although it is very difficult to measure, since we have 5 phones that return IMEI numbers of zero \ sometimes)

+6
source share
1 answer

After your comment, in order to get a unique device identifier for the polling application, I suggest you use Settings.Secure.ANDROID_ID as your unique identifier.

 String myAndroidDeviceId = Secure.getString(getApplicationContext().getContentResolver(), Secure.ANDROID_ID); 

Or you can use both as

 public String getUniqueID(){ String myAndroidDeviceId = ""; TelephonyManager mTelephony = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); if (mTelephony.getDeviceId() != null){ myAndroidDeviceId = mTelephony.getDeviceId(); }else{ myAndroidDeviceId = Secure.getString(getApplicationContext().getContentResolver(), Secure.ANDROID_ID); } return myAndroidDeviceId; } 
+4
source

All Articles