Android examples for Network:Network Status
is Network Connected
//package com.java2s; import android.content.Context; import android.net.ConnectivityManager; import android.net.NetworkInfo; public class Main { public static boolean isNetworkConnected(Context context) { try {/*from www. j a v a2 s. co 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; } }