Java tutorial
//package com.java2s; import android.content.Context; import android.net.ConnectivityManager; import android.net.NetworkInfo; public class Main { public static boolean isWifi(Context context) { ConnectivityManager mConnectivity = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo netInfo = mConnectivity.getActiveNetworkInfo(); if (netInfo == null || !mConnectivity.getBackgroundDataSetting()) { return false; } else if (ConnectivityManager.TYPE_WIFI == netInfo.getType()) { return netInfo.isConnected(); } else { return false; } } }