How to check mobile network state?

315 Views Asked by At

I'd like to be able to identify an unactivated/disconnected SIM card, i.e,

About phone>SIM status>Mobile Network State>"Disconnected"

Here are some of the things I've tried so far.

telephonyManager.simState == TelephonyManager.SIM_STATE_READY

returns true even in the disconnected scenario.

telephonyManager.dataState != TelephonyManager.DATA_DISCONNECTED

returns false even when mobile data is turned off in an active device.

Can any of the network capabilities (https://developer.android.com/reference/android/net/NetworkCapabilities#constants_1) used for this? Some indicate the connection between the carrier, but I'm unsure which one applies to this scenario.

0

There are 0 best solutions below