确定Android平板电脑是否有SIM卡插槽

时间:2013-08-08 15:24:47

标签: android sim-card

有没有办法在我的应用程序中检查平板电脑是否有SIM卡插槽?

我的要求是找出平板电脑是仅Wifi还是Wifi + Cellular设备。 我检查了Stack Overflow上提供的早期链接,但这些链接似乎都不适用于我的设备。仅Wifi单元在网络信息下返回TYPE_MOBILE。 Wifi和Cellular单位都返回PHONE_TYPE_NONESIM_STATE_UNKNOWN,因此即使这些检查也不适用。

在两种情况下返回的IMEI也为空。如果有一个有效的SIM卡插入SIM卡插槽,那么我可以验证该设备是否是蜂窝设备,但如果蜂窝设备没有插入SIM卡,或者如果SIM卡插槽坏了,那么我无法区分蜂窝和wifi +蜂窝单元

2 个答案:

答案 0 :(得分:3)

试试这段代码:

TelephonyManager tm = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE);  //gets the current TelephonyManager
if (tm.getSimState() != TelephonyManager.SIM_STATE_ABSENT){
  //the device has a sim card
} else {
  //no sim card available
}

source

答案 1 :(得分:0)

您可以检查设备支持的网络接口。然后,您可以使用ConnectivityManager检查您的设备是否支持移动数据连接。

ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
if (cm != null) {
    if (cm.getNetworkInfo(ConnectivityManager.TYPE_MOBILE) != null) {
        // the device can use mobile networks
    }
}