Here you can find the source of isConnected(final Activity act)
public static boolean isConnected(final Activity act)
//package com.java2s; //License from project: Open Source License import android.app.Activity; import android.content.Context; import android.net.ConnectivityManager; import android.net.NetworkInfo; public class Main { public static boolean isConnected(final Activity act) { final ConnectivityManager connMgr = (ConnectivityManager) act .getSystemService(Context.CONNECTIVITY_SERVICE); final NetworkInfo networkInfo = connMgr.getActiveNetworkInfo(); if (networkInfo != null && networkInfo.isConnected()) { return true; }//from ww w. j a v a 2 s .c om return false; } }