Java tutorial
//package com.java2s; //License from project: Apache License import android.content.Context; import android.net.ConnectivityManager; import android.net.NetworkInfo; public class Main { public static boolean isConnected(Context context) { NetworkInfo net = getConnManager(context).getActiveNetworkInfo(); return net != null && net.isConnected(); } public static ConnectivityManager getConnManager(Context context) { return (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); } }