Android examples for Network:Network Status
check Internet Connection Available
//package com.java2s; import android.content.Context; import android.net.ConnectivityManager; import android.net.NetworkInfo; public class Main { public static boolean checkConnectionAvailable(Context ctx) { boolean connected; ConnectivityManager connMgr = (ConnectivityManager) ctx .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connMgr.getActiveNetworkInfo(); if (networkInfo != null && networkInfo.isConnected()) { connected = true;/*from www . j a v a 2 s. c o m*/ } else { connected = false; } return connected; } }