Here you can find the source of getMobileState(Context context)
public static boolean getMobileState(Context context)
//package com.java2s; import android.content.Context; import android.net.ConnectivityManager; import android.net.NetworkInfo.State; public class Main { public static boolean getMobileState(Context context) { ConnectivityManager cm = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); State wifistate = cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI) .getState();// w ww.ja v a 2 s .c om if (wifistate != State.CONNECTED) { return false; } State mobileState = cm.getNetworkInfo( ConnectivityManager.TYPE_MOBILE).getState(); boolean ret = State.CONNECTED == mobileState; return ret; } }