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.
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.
What you want is a captive portal, which is pretty much a page that users connect to, to test whether their internet connection is working, it can be explained here in greater detail.
These open source projects look promising:
Good Luck!
The below Method works for me simply to check if the device is connected to internet or not even in universal windows app. After creating the connection class you can simply use it anywhere just by instantiating this class...
To use this class simply..
You can simply try:
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.
Please consider checking internet in background thread