The phone show me 5G, but telephoneManager.getDataNetworkType is LTE. In the settings, the sim card State show me the Mobile Voice Network Type(translate from Chinese, maybe not correct) is NR NSA (non standalone), but the Mobile data network type (translate from Chinese) is LTE.
So, how can I judge the 5G NSA or SA (standalone)?
I'm a new hand in Android, I'm not good at English, hhhh...thank you. That's my first question in Stackoverflow.
Unfortunately, you can't rely on the APIs for many of these cases. The only method I found is to register a listener to get the
ServiceState
from the TelephonyManager and then parse the result ofserviceState.toString()
This gives you the correct answer
most
of the times. BTWNR NSA
is the correct name for NR non-standalone.If you want to distinguish between NRSA and NRNSA you need to fetch all the cellInfo from the TelephonyManager
and check whether the primary cell is NR.
In some cases what you will see is that there are no NR cells. In that case, you can be sure that the connection is NRNSA (assuming that it is 5G). In other cases, there will be NR cells but they won't be reported as primary-cell. It is possible that the device will even report the NR cell as not connected at all even if it is used. Again in that case you know it is NRNSA. You might detect the NR cell that is used even if it is reported as not connected by checking the strengths.
You will see that the strength reported is the same as the strength of the NR cell with the highest SS-RSRP (Synchronization Signal Reference Signal Received Power)
I would avoid using the
TelephonyDisplayInfo
since it is not reliable. These values are shown to the users and they follow the carrier policy or brand preferences.