Check Network Availability in Android

by Sasikumar 2013-10-16 14:33:25

Check Network Availability in Android :
To check whether network is available in android device you can use the following function:

public static boolean checkNetworkAvailability(Context mcontext)
{
ConnectivityManager cManager = (ConnectivityManager)mcontext.getSystemService(Context.CONNECTIVITY_SERVICE);
if(cManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI).isConnected() || cManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).isConnected())
{
return true;
}
return false;
}

Just make a call to this function with the context of the activity, this would return true if network is available and false when network is low or nil.

This function will check whether network is available either in mobile or in Wi-Fi.
722
like
0
dislike
0
mail
flag

You must LOGIN to add comments