Java tutorial
//package com.java2s; import android.content.Context; import android.net.ConnectivityManager; import android.net.NetworkInfo; public class Main { public static NetworkInfo getCurrentActiveNetwork(Context mContext) { try { ConnectivityManager connectivity = (ConnectivityManager) mContext .getSystemService(Context.CONNECTIVITY_SERVICE); if (connectivity != null) { return connectivity.getActiveNetworkInfo(); } } catch (Exception e) { e.printStackTrace(); } return null; } }