Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
How To Check Network Connectivity In Xamarin.Forms
WhatsApp
Virendra Thakur
8y
101.4
k
0
3
25
Blog
Introduction
Network connectivity refers to the internet connectivity of a device, which can be either mobile data or Wi-Fi. In Xamarin.Forms, we are creating cross platform apps, so the different platforms have different implementations. In this blog, we will learn how to check internet connectivity in Xamarin.Forms apps.
Solution
To check the internet connection in Xamarin.Forms app, we need to follow the steps given below.
Step 1
Go to your solution and on your Portable project, right click and select Manage NuGet Packages.
Step 2
Search and install Xam.Plugin.Connectivity NuGet Package.
Step 3
Write the lines of code given below to check the internet connectivity.
if
(CrossConnectivity.Current.IsConnected) {
// your logic...
}
else
{
// write your code if there is no Internet available
}
Note
In Android platform, you have to allow the user permission to check internet connectivity. For this, use the steps given below.
Step 3(a)
Go to Droid Project, double click on properties and select Android Manifest option.
Step 3(b)
Now, select ACCESS_NETWORK_STATE and INTERNET permission. Save it and this permission will help the user to check the network state and access the internet.
Thus, we have learnt how to check internet connectivity in Xamarin.Forms app.
Network Connectivity
Xamarin Forms
Up Next
Using ZXing (Code 128 Scanner) In Xamarin Forms
Ebook Download
View all
Xamarin.Forms For Beginners
Read by 9.1k people
Download Now!
Learn
View all
Membership not found