对于IMEI号,TelephonyManager返回null:可能导致此问题的原因是什么?

Zac*_*ith 8 android imei telephonymanager

我正在开发Android应用程序,并null在使用时回来查看IMEI号码TelophonyManager.这在几部华为手机上都有发生.(所有这些都是Ascend Y530s).

手机都有SIM卡,否则看起来运行正常.我的印象是只有破损的手机会返回nullIMEI.显然情况并非如此......

问题.这个IMEI号究竟是什么 - 即它存储在设备上的哪个位置?当看似精美的手机恢复其价值时,它意味着什么null

编辑

我应该提到IMEI号并不总是如此null.大概有一半的时间似乎是有效的(虽然这很难衡量,因为我们有5部电话有时返回空的IMEI号码\ )

Let*_*tor 5

发表评论后,要获取调查应用程序的唯一设备ID,我建议您将其Settings.Secure.ANDROID_ID用作唯一ID。

String   myAndroidDeviceId = Secure.getString(getApplicationContext().getContentResolver(), Secure.ANDROID_ID);
Run Code Online (Sandbox Code Playgroud)

或者您可以将两者都用作

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;
}
Run Code Online (Sandbox Code Playgroud)

  • 从技术上讲,我很想知道导致此问题的可能原因是什么? (2认同)
  • 在 Android Q 上获取 IMEI 为空?有没有人也发现这个? (2认同)