Java tutorial
//package com.java2s; //License from project: Open Source License import android.content.Context; import android.net.ConnectivityManager; public class Main { public static boolean CheckNetwork(Context context) { boolean bool = false; ConnectivityManager localConnectivityManager = (ConnectivityManager) context .getSystemService("connectivity"); if (localConnectivityManager.getActiveNetworkInfo() != null) bool = localConnectivityManager.getActiveNetworkInfo().isAvailable(); return bool; } }