Android Check Internet Connection Tutorial with Example

By | July 19, 2019
Detect Internet Connection in Android Tutorial Example

How to check/Detect Internet Connection in Android ?

In Android Provides Detect or Check Internet Connection in Your App is Available or not.It is used To  ConnectivityManager class It can easily determine the network or internet connected or not and it can determine the type of internet connection currently available i.e. whether it’s mobile data or Wi-Fi.

Your App is perform any network related operation like making HTTP request, then it is good to check internet or network connectivity.

You can Check Your App Internet Connection status you must required INTERNET And ACCESS_NETWORK_STATE Permission in AndroidManiFest File.

You can get information of all networks using getAllNetworkInfo() method. This method will return an array of NetworkInfo type.

Example of Check Internet Connection in Android

Declared Permission in AndroidManifest.xml File Required.

Create activity_main.xml File Follow this Code.

Create File Follow this Code.

Above the Example to create simple button and click the button to check internet connection. you can disconnected to internet to display internet not connected.when you can connect internet on your WiFi or mobile data to display Internet Connected Message.