Zach Smith Zach Smith - 1 year ago 93
Android Question

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

I'm working on an Android app and am getting

back for the IMEI number when using
. This is happening on several Huawei phones. (All of them are Ascend Y530s).

The phones all have sim cards and otherwise seem to be operating normally. I was under the impression that only a broken phone would return
IMEI. Clearly this is not the case..

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


I should mention that the IMEI number is not always
. About half the time it seems to be valid (though this is very difficult to measure since we have 5 phones returning null IMEI numbers \ sometimes )

Answer Source

After your comment, to get unique device id for the survey app, i would suggest you to use Settings.Secure.ANDROID_ID as your unique id.

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(); 
         myAndroidDeviceId = Secure.getString(getApplicationContext().getContentResolver(), Secure.ANDROID_ID); 
    return myAndroidDeviceId;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download