Android Network State Check isConnectedMobile(Context context)

Here you can find the source of isConnectedMobile(Context context)

Description

is Connected Mobile

Declaration

public static boolean isConnectedMobile(Context context) 

Method Source Code

//package com.java2s;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

public class Main {
    public static boolean isConnectedMobile(Context context) {
        NetworkInfo info = getNetworkInfo(context);
        return isConnected(info)
                && info.getType() == ConnectivityManager.TYPE_MOBILE;
    }/* ww  w  .j av a2s .co  m*/

    public static NetworkInfo getNetworkInfo(Context context) {
        ConnectivityManager cm = (ConnectivityManager) context
                .getSystemService(Context.CONNECTIVITY_SERVICE);
        return cm.getActiveNetworkInfo();
    }

    public static boolean isConnected(Context context) {
        NetworkInfo info = getNetworkInfo(context);
        return isConnected(info);
    }

    public static boolean isConnected(NetworkInfo info) {
        return info != null && info.isConnected();
    }
}

Related

  1. isConnected(Context context)
  2. isConnected(NetworkInfo info)
  3. isConnected(final Context context, final int... networkTypes)
  4. isConnected(final NetworkInfo info)
  5. isConnectedFast(Context context)
  6. isConnectedMobile(Context context)
  7. isConnectingToInternet()
  8. isConnectingToInternet(Context context)
  9. isConnectionFast(int type, int subType)