Here you can find the source of onNetwork(Context context)
public static boolean onNetwork(Context context)
//package com.java2s; import android.content.Context; import android.net.ConnectivityManager; import android.net.NetworkInfo; public class Main { public static boolean onNetwork(Context context) { final ConnectivityManager conMgr = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); final NetworkInfo activeNetwork = conMgr.getActiveNetworkInfo(); if (activeNetwork != null && activeNetwork.isConnected()) { return true; } else {/*from w w w .j av a2 s . c o m*/ return false; } } }