List of usage examples for android.net NetworkInfo getType
@Deprecated public int getType()
From source file:Main.java
public static boolean isActiveNetworkMobile(Context context) { ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); if (connectivityManager != null) { NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo(); if (networkInfo != null && networkInfo.getType() == ConnectivityManager.TYPE_MOBILE) { return true; }//from ww w . j a v a 2 s .c o m } return false; }
From source file:Main.java
public static boolean isWifiConnected(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); if (cm != null) { NetworkInfo networkInfo = cm.getActiveNetworkInfo(); if (networkInfo != null && networkInfo.getType() == ConnectivityManager.TYPE_WIFI) { return true; }/*from www . ja va 2s .c om*/ } return false; }
From source file:Main.java
public static boolean isWifiConnected(Context context) { ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo info = manager.getActiveNetworkInfo(); return info != null && info.isConnected() && info.getType() == ConnectivityManager.TYPE_WIFI; }
From source file:Main.java
public static boolean isOnWifiNetwork(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); if (activeNetwork != null) { return activeNetwork.getType() == ConnectivityManager.TYPE_WIFI; } else {//from ww w . j av a2 s . co m return false; } }
From source file:Main.java
public static String isNetWorkType(Context cxt) { ConnectivityManager connectivityManager = (ConnectivityManager) cxt .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetInfo = connectivityManager.getActiveNetworkInfo(); if (activeNetInfo != null && activeNetInfo.getType() == ConnectivityManager.TYPE_MOBILE) { return "3G"; }// w ww. ja va 2 s . c o m if (activeNetInfo != null && activeNetInfo.getType() == ConnectivityManager.TYPE_WIFI) { return "WIFI"; } return ""; }
From source file:Main.java
public static int isHightBandwidthConnection(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo info = cm.getActiveNetworkInfo(); return isConnectionFast(info.getType(), info.getSubtype()); }
From source file:Main.java
public static boolean isWifiConnected(Context context) { if (context == null) { return false; }//from w ww .j a v a 2s . c o m ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetInfo = connectivityManager.getActiveNetworkInfo(); return (activeNetInfo != null) && (activeNetInfo.getType() == ConnectivityManager.TYPE_WIFI); }
From source file:Main.java
public static int getConnectivityStatus(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); if (null != activeNetwork) { if (activeNetwork.getType() == ConnectivityManager.TYPE_WIFI) return TYPE_WIFI; if (activeNetwork.getType() == ConnectivityManager.TYPE_MOBILE) return TYPE_MOBILE; }//from w w w.j a va 2s . c o m return TYPE_NOT_CONNECTED; }
From source file:Main.java
public static boolean isWifi(Context mContext) { ConnectivityManager connectivityManager = (ConnectivityManager) mContext .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetInfo = connectivityManager.getActiveNetworkInfo(); return activeNetInfo != null && activeNetInfo.getType() == ConnectivityManager.TYPE_WIFI; }
From source file:Main.java
public static boolean isMobile(Context context) { ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetInfo = connectivityManager.getActiveNetworkInfo(); return activeNetInfo != null && activeNetInfo.getType() == ConnectivityManager.TYPE_MOBILE; }