Java tutorial
//package com.java2s; import android.app.Activity; import android.net.ConnectivityManager; import android.net.NetworkInfo; public class Main { /** * @author Cheb * @return Internet connectivity status */ public static boolean isConnectingToInternet(Activity activity) { ConnectivityManager connectivity = (ConnectivityManager) activity .getSystemService(activity.CONNECTIVITY_SERVICE); if (connectivity != null) { NetworkInfo[] info = connectivity.getAllNetworkInfo(); if (info != null) { for (int i = 0; i < info.length; i++) { if (info[i].getState() == NetworkInfo.State.CONNECTED) { return true; } } } } return false; } }