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) { try {/*from w w w . j a v a 2 s . c o m*/ ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetworkInfo = connectivityManager .getActiveNetworkInfo(); return activeNetworkInfo != null; } catch (Exception e) { } return false; } }