TelephonyManager的IMEI号码返回空值:这是什么原因引起的? [英] TelephonyManager returns null for IMEI number: what can cause this?

查看:639
本文介绍了TelephonyManager的IMEI号码返回空值:这是什么原因引起的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个Android应用程序,并且在使用TelophonyManager时正在获取null的IMEI号码.这在几款华为手机上都在发生. (它们都是Ascend Y530).

I'm working on an Android app and am getting null back for the IMEI number when using TelophonyManager. This is happening on several Huawei phones. (All of them are Ascend Y530s).

所有手机均具有SIM卡,否则似乎可以正常运行.我的印象是只有坏掉的手机才能返回null IMEI.显然不是这种情况.

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 null IMEI. Clearly this is not the case..

问题.此IMEI编号到底是什么-即它存储在设备上的什么位置?看起来不错的手机返回其值为null的含义是什么?

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 null?

编辑

我应该提到IMEI号码并不总是null.大约有一半的时间似乎是有效的(尽管这很难衡量,因为我们有5部手机返回空IMEI号码\ 有时)

I should mention that the IMEI number is not always null. 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 )

推荐答案

发表评论后,要获取调查应用程序的唯一设备ID,我建议您使用

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);

或者您也可以同时使用

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;
}

这篇关于TelephonyManager的IMEI号码返回空值:这是什么原因引起的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆