Here you can find the source of CheckInternet(Activity a)
public static boolean CheckInternet(Activity a)
//package com.java2s; //License from project: Open Source License import android.app.Activity; import android.content.Context; import android.net.ConnectivityManager; public class Main { public static boolean CheckInternet(Activity a) { ConnectivityManager connec = (ConnectivityManager) a .getBaseContext().getSystemService( Context.CONNECTIVITY_SERVICE); android.net.NetworkInfo wifi = connec .getNetworkInfo(ConnectivityManager.TYPE_WIFI); android.net.NetworkInfo mobile = connec .getNetworkInfo(ConnectivityManager.TYPE_MOBILE); if (wifi.isConnected()) { return true; } else if (mobile.isConnected()) { return true; }//ww w. j a v a 2s .c om return false; } }