I wanted to check whether my phone can connect to Internet or not. I have seen several questions already. One of those is Question . It says to use NetworkInterface.GetIsNetworkAvailable()
this and i tried it. I have disconnected my PC from internet and Also turned off the DataConnection
of the emulator but NetworkInterface.GetIsNetworkAvailable()
this always returning true. But simultaneouly i also check for NetworkInterfaceType.None
and interestingly it is coming null.
Can anybody explain where i am missing info ?
Attempt : -
public static void CheckNetworkAvailability()
{
// this is coming true even when i disconnected my pc from internet.
// i also make the dataconnection off of the emulator
var fg = NetworkInterface.GetIsNetworkAvailable();
var ni = NetworkInterface.NetworkInterfaceType;
// this part is coming none
if (ni == NetworkInterfaceType.None)
IsConnected = false;
}
any help is appreciated :)