TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
How To Check Network Connectivity In Xamarin.Forms
Virendra Thakur
Jan 03, 2017
101.3
k
0
3
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
In this blog, you will learn how to check network connectivity in Xamarin.Forms.
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
Next Recommended Reading
Using ZXing (Code 128 Scanner) In Xamarin Forms