I have this fuction. But i get error on this line:|
int nrState = regInfo.getNrState();
Message:
Cannot resolve method 'getNrState' in 'NetworkRegistrationInfo
Can someone where i make mistake? Or I should do this in differend way?
ServiceState serviceState = telephonyManager.getServiceState();
if (serviceState != null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
for (NetworkRegistrationInfo regInfo : serviceState.getNetworkRegistrationInfoList()) {
if (regInfo.getAccessNetworkTechnology() == TelephonyManager.NETWORK_TYPE_NR) {
int nrState = regInfo.getNrState(); // 👈
switch (nrState) {
case NetworkRegistrationInfo.NR_STATE_NONE:
return "Not in NR state";
case NetworkRegistrationInfo.NR_STATE_RESTRICTED:
return "Restricted NR state";
case NetworkRegistrationInfo.NR_STATE_NOT_RESTRICTED:
return "Non-restricted NR state";
case NetworkRegistrationInfo.NR_STATE_CONNECTED:
return "Connected to 5G NR";
}
}
}
}
}
I need access to getNrState() for each sim card.