Here you can find the source of isNetworkAvailable()
public static boolean isNetworkAvailable()
//package com.java2s; import android.content.Context; import android.net.ConnectivityManager; public class Main { /**//from w ww . j ava 2s . c o m * The context of the Android application or widget. */ private static Context context; /** * Uses Android connectivity service to give information about the * availability of the network on the phone. * * @return * true if the network is available. */ public static boolean isNetworkAvailable() { if (context != null) { ConnectivityManager connMgr = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); return connMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI) .isConnected() || connMgr.getNetworkInfo( ConnectivityManager.TYPE_MOBILE).isConnected(); } return false; } }