I am trying to detect 5G Nr cell info on Samsung S20 (T-Mobile) using Android API
CellIdentityNr https://developer.android.com/reference/android/telephony/CellIdentityNr.html and
CellSignalStrengthNr https://developer.android.com/reference/android/telephony/CellSignalStrengthNr
Here is my code which detects the cell info:
try {
if (cellInfo instanceof CellInfoGsm) {
CellInfoGsm cellInfoGsm = (CellInfoGsm) cellInfo;
logGSMCellInfo(cellInfoGsm, allCellInfoProps);
} else if (cellInfo instanceof CellInfoLte) {
CellInfoLte cellInfoLte = (CellInfoLte) cellInfo;
logLTECellInfo(cellInfoLte, allCellInfoProps);
} else if (cellInfo instanceof CellInfoCdma) {
CellInfoCdma cellInfoCdma = (CellInfoCdma) cellInfo;
logCDMACellInfo(cellInfoCdma, allCellInfoProps);
} else if (cellInfo instanceof CellInfoWcdma) {
CellInfoWcdma cellInfoWcdma = (CellInfoWcdma) cellInfo;
logWCDMACellInfo(cellInfoWcdma, allCellInfoProps);
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
if (cellInfo instanceof CellInfoTdscdma) {
CellInfoTdscdma cellInfoTdscdma = (CellInfoTdscdma) cellInfo;
logTDSCDMACellInfo(cellInfoTdscdma, allCellInfoProps);
} else if (cellInfo instanceof CellInfoNr) {
CellInfoNr cellInfoNr = (CellInfoNr) cellInfo;
logNrCellInfo(cellInfoNr, allCellInfoProps);
}
}
collectionOfCellInfo.add(allCellInfoProps);
} catch (Exception e) {
Log.e(TAG, "getLatestCellInfoAsCollection: Exception=" + e.getMessage());
e.printStackTrace();
}
The problem is that even when the phone is showing 5G in the top bar indicating 5G connection I am getting WCDMA cell info when I should be getting Nr.
From this link, I gathered that the CellInfoNr object is only collected on NR-SA devices, which would explain why I can't get Nr info on other phones. But why am I not getting it on Samsung S20? Detect 5G NR (SA/NSA) in my Android Application
Is there something wrong with the code, or is this problem caused due to available 5G network mode?
Also how to confirm that my S20 is in 'Standalone (5G)' mode?
Hashim - I can determine if the network is connected with the code below - but I cannot figure out how to get the CellInfoNR to get the 5G signal strength.
Have you figured out how to get teh CellInfoNR to get all of the details on the 5G Connection?
and then this is the class:
}