List of usage examples for android.net ConnectivityManager TYPE_MOBILE
int TYPE_MOBILE
To view the source code for android.net ConnectivityManager TYPE_MOBILE.
Click Source Link
From source file:Main.java
public static boolean isOnlineOnMobile(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); return (activeNetwork != null && activeNetwork.getType() == ConnectivityManager.TYPE_MOBILE); }
From source file:Main.java
public static boolean isMobileConnection(Context context) { ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo.State mobile = null; if (connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE) != null) { mobile = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).getState(); }// w w w .j a v a2 s. c om return (mobile != null && mobile.equals(NetworkInfo.State.CONNECTED)); }
From source file:Main.java
public static boolean isConnectionToMobile(Context applicationContext) { ConnectivityManager connectivityManager = (ConnectivityManager) applicationContext .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE); if (networkInfo != null && networkInfo.isConnectedOrConnecting()) { return true; }/*from ww w . j a v a2 s . c o m*/ return false; }
From source file:Main.java
public static boolean checkMobileNET(Context cxt) { ConnectivityManager cm = (ConnectivityManager) cxt.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); if (activeNetwork.getType() == ConnectivityManager.TYPE_MOBILE) return true; else// ww w. j a v a2 s . c om return false; }
From source file:Main.java
public static boolean CheckNetworkConnect(Context context) { boolean result = false; ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo mobileInfo = manager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE); NetworkInfo wifiInfo = manager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); NetworkInfo ethInfo = manager.getNetworkInfo(ConnectivityManager.TYPE_ETHERNET); NetworkInfo activeInfo = manager.getActiveNetworkInfo(); Log.v("networkInfo", "mobile:" + mobileInfo.isConnected() + "\n" + "wifi:" + wifiInfo.isConnected() + "\n" + "eth:" + ethInfo.isConnected() + "\n" + "active:" + activeInfo.getTypeName()); if (wifiInfo.isConnected() || ethInfo.isConnected()) { result = true;//from w w w. j a v a 2s . c om } return result; }
From source file:Main.java
public static boolean isMobileOnline(Context context) { ConnectivityManager conMan = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); State mobile = conMan.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).getState(); if (mobile == NetworkInfo.State.CONNECTED) return true; else/*from w ww. ja v a 2s .c o m*/ return false; }
From source file:Main.java
public static boolean isMobileConnected(Context context) { if (context != null) { ConnectivityManager connManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo mobileInfo = connManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE); if (mobileInfo != null) { return mobileInfo.isAvailable(); }/*from w w w . java 2s .com*/ } return false; }
From source file:Main.java
public static boolean check3GNetworkInfo(Context context) { try {//w w w .j av a2 s . c o m ConnectivityManager conMan = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); //mobile 3G Data Network State mobile = conMan.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).getState(); return (mobile == State.CONNECTED || mobile == State.CONNECTING); } catch (Exception e) { return false; } }
From source file:Main.java
public static int getNetworkType(Context context) { ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); State mobileState = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).getState(); State wifiState = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI).getState(); if (wifiState == State.CONNECTED || wifiState == State.CONNECTING) { return 1; } else if (mobileState == State.CONNECTED || mobileState == State.CONNECTING) { return 2; } else {//from www .j a v a 2 s. com return 0; } }
From source file:Main.java
public static boolean is3G(Context context) { try {/*from w w w. j a v a 2 s.c o m*/ ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); if (cm != null) { NetworkInfo ni = cm.getActiveNetworkInfo(); if (ni != null && ni.getType() == ConnectivityManager.TYPE_MOBILE) { return true; } } } catch (Exception e) { } return false; }