Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows Phone 8.1: Check Internet Connection

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.

like image 606
Vahid Avatar asked Oct 20 '22 20:10

Vahid


1 Answers

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.

like image 177
TrueMatoriv Avatar answered Oct 24 '22 01:10

TrueMatoriv