How can I know if the phone has internet connection? (Whether WiFi or Data)
Sometimes the phone is connecting to WiFi without internet connection like HotSpots. So I want a code to know if the phone is connecting to internet.
You can simply try:
if (NetworkInformation.GetInternetConnectionProfile() == null)
{
//no connection
}
As you can see in this msdn documentation:NetworkInformation.GetInternetConnectionProfile
It will return null if there is "no connection profile with a suitable connection"
You can also check explicity the "Internet Access" level with this: NetworkInformation.GetInternetConnectionProfile().GetNetworkConnectivityLevel() == NetworkConnectivityLevel.InternetAccess
I Think this will work also in universal app.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With