私のアプリケーションでは、を使用して Sim が存在するかどうかを確認していsimState == TelephonyManager.SIM_STATE_ABSENT
ます。Sim が存在する場合、Sim のオペレーター名、Sim の国など、すべての Sim 情報を収集します。WiFi をオフにすると、Sim が存在していても、Sim が不在になり、Sim の詳細を取得できません。( 電話管理者が Sim にアクセスしていないWi-Fi未接続時。)
- 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");
}
}
前もって感謝します。