Java tutorial
//package com.java2s; import android.content.Context; import android.net.ConnectivityManager; public class Main { public static boolean isOpenNetwork(Context context) { if (null == context) { return false; } ConnectivityManager connManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); if (connManager.getActiveNetworkInfo() != null) { return connManager.getActiveNetworkInfo().isAvailable(); } return false; } }