Java tutorial
//package com.java2s; //License from project: Apache License import android.content.Context; import android.net.ConnectivityManager; import android.net.NetworkInfo; public class Main { /** * Returns <tt>true</tt> if the Connections is available. Else returns <tt>false</tt>. * * @return */ public static boolean isConnectedOnline(Context myContext) { ConnectivityManager cmObj = (ConnectivityManager) myContext.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfoObj = cmObj.getActiveNetworkInfo(); return networkInfoObj != null && networkInfoObj.isConnected(); } }