Here you can find the source of isOnline(Context context)
Parameter | Description |
---|---|
context | The application context |
static public boolean isOnline(Context context)
//package com.java2s; import android.content.Context; import android.net.ConnectivityManager; import android.net.NetworkInfo; public class Main { /**//from ww w. j av a2s . com * Check if internet connection is up * * @param context The application context * @return True if it's up, false if it's not */ static public boolean isOnline(Context context) { ConnectivityManager cm = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo netInfo = cm.getActiveNetworkInfo(); return netInfo != null && netInfo.isConnectedOrConnecting(); } }