Here you can find the source of isNetworkAvailable(Context context)
public static boolean isNetworkAvailable(Context context)
//package com.java2s; import android.content.Context; import android.net.ConnectivityManager; import android.net.NetworkInfo; public class Main { public static boolean isNetworkAvailable(Context context) { ConnectivityManager conMgr = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); boolean availability = false; try {//from ww w.j a va 2 s . c om if (conMgr.getNetworkInfo(ConnectivityManager.TYPE_MOBILE) .getState() == NetworkInfo.State.CONNECTED || conMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI) .getState() == NetworkInfo.State.CONNECTED) { availability = true; } } catch (Exception e) { return true; } return availability; } }