Here you can find the source of isOnline(Context context)
public static boolean isOnline(Context context)
//package com.java2s; import android.net.ConnectivityManager; import android.net.ConnectivityManager; import android.content.Context; public class Main { public static boolean isOnline(Context context) { ConnectivityManager con_manager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); return con_manager.getActiveNetworkInfo() != null && con_manager.getActiveNetworkInfo().isAvailable() && con_manager.getActiveNetworkInfo().isConnected(); }/*from ww w . j ava2 s . c o m*/ }