Java tutorial
//package com.java2s; import android.content.Context; import android.net.ConnectivityManager; import android.net.NetworkInfo; public class Main { /** * Check if there is any connectivity to a Wifi network. * <p/> * Can be used in combination with {@link #isConnectedMobile} * to provide different features if the device is on a wifi network or a cell network. * * @param context The current Context or Activity that this method is called from * @return true if a wifi connection is available, otherwise false. */ public static boolean isConnectedWifi(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo info = cm.getActiveNetworkInfo(); return (info != null && info.isConnected() && info.getType() == ConnectivityManager.TYPE_WIFI); } }