在我的应用程序中,我使用 . 检查 Sim 是否存在simState == TelephonyManager.SIM_STATE_ABSENT
。如果 Sim 存在,我将收集所有 Sim 信息,例如 Sim 运营商名称、Sim 国家/地区等。如果我关闭 WiFi,即使它存在,我也会得到 Sim 缺席,并且我没有得到任何 Sim 详细信息。(电话管理员无法访问 sim当 wifi 未连接时。)
- WiFi关闭时,还有其他方法可以获取SIM卡信息吗?
TelephonyManager telephonyManager =
((TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE));
int simState = telephonyManager.getSimState();
if (simState == TelephonyManager.SIM_STATE_ABSENT){
Log.d("hello", "network disconnected");
operatorParam.add("Not found");
operatorParam.add("Not found");
operatorParam.add("Not found");
operatorParam.add("Not found");
operatorParam.add("Not found");
operatorParam.add("Not found");
} else {
Log.d("hello", "network connected");
if (telephonyManager.getNetworkOperatorName() != null) {
operatorParam.add(telephonyManager.getNetworkOperatorName());
Log.d("operator", "getoperator name not null: "
+ telephonyManager.getNetworkOperatorName());
} else {
operatorParam.add("Not found");
}
if (telephonyManager.getSimOperatorName() != null) {
operatorParam.add(telephonyManager.getSimOperatorName());
} else {
operatorParam.add("Not found");
}
if (telephonyManager.getSimOperator() != null) {
operatorParam.add(telephonyManager.getSimOperator());
} else {
operatorParam.add("Not found");
}
if (telephonyManager.getSimSerialNumber() != null) {
operatorParam.add(telephonyManager.getSimSerialNumber());
} else {
operatorParam.add("Not found");
}
if (telephonyManager.getSimCountryIso() != null) {
operatorParam.add(telephonyManager.getSimCountryIso());
} else {
operatorParam.add("Not found");
}
if (telephonyManager.getSubscriberId() != null) {
operatorParam.add(telephonyManager.getSubscriberId());
} else {
operatorParam.add("Not found");
}
}
提前致谢。