The Connectivity class lets you monitor for changes in the device's network conditions, check the current network access, and how it is currently connected.
To start using this API, read the getting started guide for Xamarin.Essentials to ensure the library is properly installed and set up in your projects.
To access the Connectivity functionality the following platform specific setup is required.
AccessNetworkState permission is required and must be configured in the Android project. This can be added in the following ways:
Open the AssemblyInfo.cs file under the Properties folder and add:
OR Update Android Manifest:
Open the AndroidManifest.xml file under the Properties folder and add the following inside of the manifest node.
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Or right click on the Android project and open the project's properties. Under Android Manifest find the Required permissions: area and check the Access Network State permission. This will automatically update the AndroidManifest.xml file.
Add a reference to Xamarin.Essentials in your class:
Check current network access:
var current = Connectivity.NetworkAccess;
if (current == NetworkAccess.Internet)
// Connection to internet is available
Network access falls into the following categories:
- Internet – Local and internet access.
- ConstrainedInternet – Limited internet access. Indicates captive portal connectivity, where local access to a web portal is provided, but access to the Internet requires that specific credentials are provided via a portal.
- Local – Local network access only.
- None – No connectivity is available.
- Unknown – Unable to determine internet connectivity.
You can check what type of connection profile the device is actively using:
var profiles = Connectivity.ConnectionProfiles;
// Active Wi-Fi connection.
Whenever the connection profile or network access changes you can receive an event when triggered:
public class ConnectivityTest
// Register for connectivity changes, be sure to unsubscribe when finished
Connectivity.ConnectivityChanged += Connectivity_ConnectivityChanged;
void Connectivity_ConnectivityChanged(object sender, ConnectivityChangedEventArgs e)
var access = e.NetworkAccess;
var profiles = e.ConnectionProfiles;
It is important to note that it is possible that
Internet is reported by
NetworkAccess but full access to the web is not available. Due to how connectivity works on each platform it can only guarantee that a connection is available. For instance the device may be connected to a Wi-Fi network, but the router is disconnected from the internet. In this instance Internet may be reported, but an active connection is not available.