Java tutorial
//package com.java2s; import android.content.Context; import android.net.ConnectivityManager; import android.net.NetworkInfo; public class Main { public static boolean isNetConnected(Context context) { if (context == null) { return true; } ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo nwInfo = connectivityManager.getActiveNetworkInfo(); if (nwInfo != null && nwInfo.isConnectedOrConnecting()) { return true; } return false; } }