在我的应用程序中,我使用simState == TelephonyManager.SIM_STATE_ABSENT
检查Sim是否存在。如果Sim存在,我正在收集所有Sim信息,如Sim操作员名称,Sim国家等。如果我关闭WiFi,我会让Sim缺席,即使它存在,我也没有得到任何Sim详细信息。(电话经理不访问sim当wifi没有连接时。)
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");
}
}
提前感谢。