我正在开发一个 Android 应用程序,并且正在得到null
使用时返回 IMEI 号码TelophonyManager
。多款华为手机都出现这种情况。 (均为 Ascend Y530)。
这些手机都有 SIM 卡,其他方面似乎都运行正常。我的印象是只有坏掉的手机才会回来null
IMEI。显然事实并非如此..
问题。这个 IMEI 号码到底是什么 - 即它存储在设备上的什么位置?当一款看似不错的手机回归它的价值时,这意味着什么?null
?
EDIT
我应该提到 IMEI 号码并不总是null
。大约一半的时间似乎是有效的(尽管这很难测量,因为我们有 5 部手机返回空 IMEI 号码\有时 )
在您发表评论后,要获取调查应用程序的唯一设备 ID,我建议您使用Settings.Secure.ANDROID_ID作为您的唯一 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;
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)