Here you can find the source of checkNetWorkStatus(Context context)
public static int checkNetWorkStatus(Context context)
//package com.java2s; import android.content.Context; import android.net.ConnectivityManager; public class Main { public static final int WIFI_ON = 0; public static final int WIFI_OFF = 1; public static final int MOBILE_ON = 2; public static final int MOBILE_OFF = 3; public static int checkNetWorkStatus(Context context) { int status = 0; ConnectivityManager connMgr = (ConnectivityManager) context .getApplicationContext().getSystemService( Context.CONNECTIVITY_SERVICE); android.net.NetworkInfo wifi = connMgr .getNetworkInfo(ConnectivityManager.TYPE_WIFI); android.net.NetworkInfo mobile = connMgr .getNetworkInfo(ConnectivityManager.TYPE_MOBILE); if (wifi.isConnectedOrConnecting()) { status = WIFI_ON;/*from w w w . j a v a2s .co m*/ } else { status = WIFI_OFF; } if (mobile.isConnectedOrConnecting()) { status = MOBILE_ON; } else { status = MOBILE_OFF; } return status; } }