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; import android.util.Log; public class Main { public static boolean isNetworkAvailable(Context context) { ConnectivityManager connectivity = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); if (connectivity == null) { Log.i("NetWorkState", "Unavailabel"); return false; } else {/* w w w. ja v a 2 s.co m*/ NetworkInfo[] info = connectivity.getAllNetworkInfo(); if (info != null) { for (int i = 0; i < info.length; i++) { if (info[i].getState() == NetworkInfo.State.CONNECTED) { Log.i("NetWorkState", "Availabel"); return true; } } } } return false; } }