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