Android examples for android.net:ConnectivityManager
is Network Connected using NetworkInfo
import android.content.Context; import android.net.ConnectivityManager; import android.net.NetworkInfo; public class Main { public static boolean isNetworkConnected(Context context) { try {/*from w w w .jav a 2s. c o m*/ ConnectivityManager conn = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo net = conn.getActiveNetworkInfo(); if (net != null && net.isConnected()) { return true; } } catch (Exception e) { return false; } return false; } }