Java tutorial
//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(); if (wifistate != State.CONNECTED) { return false; } State mobileState = cm.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).getState(); boolean ret = State.CONNECTED == mobileState; return ret; } }