Android examples for Network:Network Status
is Mobile Network Available
//package com.java2s; import android.content.Context; import android.net.ConnectivityManager; import android.net.NetworkInfo; public class Main { public static boolean isMobileNetworkAvailable(Context context) { ConnectivityManager manager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo wifiInfo = manager//from www . j a va 2 s .c o m .getNetworkInfo(ConnectivityManager.TYPE_WIFI); NetworkInfo mobileInfo = manager .getNetworkInfo(ConnectivityManager.TYPE_MOBILE); return (wifiInfo == null ? false : wifiInfo.isConnected()) || (mobileInfo == null ? false : mobileInfo.isConnected()); } }