Java tutorial
//package com.java2s; import android.content.Context; import android.net.ConnectivityManager; import android.net.NetworkInfo; public class Main { public static String currentNetwork(Context ctx) { ConnectivityManager cm = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo info = cm.getActiveNetworkInfo(); if (info != null) { if (info.isAvailable() && info.isConnectedOrConnecting()) { String netType = info.getTypeName(); if ("WIFI".equals(netType)) { return "WIFI"; } else { return "2G/3G"; } } } return null; } }