Android examples for Phone:Network
is Network Available
//package com.java2s; import android.content.Context; import android.net.ConnectivityManager; import android.net.NetworkInfo; public class Main { public static boolean isNetworkAvailable(Context context) { ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); if (connectivityManager == null) { return false; }// w ww . java2 s . co m NetworkInfo networkInfo = connectivityManager .getActiveNetworkInfo(); return networkInfo != null && networkInfo.isConnected(); } }