List of usage examples for android.content Context CONNECTIVITY_SERVICE
String CONNECTIVITY_SERVICE
To view the source code for android.content Context CONNECTIVITY_SERVICE.
Click Source Link
From source file:Main.java
public static boolean checkNetwork(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = cm.getActiveNetworkInfo(); if (networkInfo != null) { if (networkInfo.isConnected()) { return true; }//from w ww . j a v a 2 s . c om } return false; }
From source file:Main.java
public static boolean isWifiConnected(Context context) { final ConnectivityManager connMgr = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); final android.net.NetworkInfo wifi = connMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI); if (wifi.isAvailable()) return true; else// ww w. j a v a2 s . co m return false; }
From source file:Main.java
public static boolean isNetConnect(Context context) { ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = manager.getActiveNetworkInfo(); if (networkInfo != null && networkInfo.isConnected()) { return true; } else {// w w w . j a v a2 s .c om return false; } }
From source file:Main.java
public static boolean checkNetwork(Context context) { ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkinfo = manager.getActiveNetworkInfo(); if (networkinfo != null) { if (networkinfo.isConnected()) { return true; }// w w w. ja v a 2 s . c om } return false; }
From source file:Main.java
public static boolean isWifiConnected(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkINfo = cm.getActiveNetworkInfo(); if (networkINfo != null && networkINfo.isAvailable() && networkINfo.getType() == ConnectivityManager.TYPE_WIFI) { return true; }/*from ww w . j a va2 s. c om*/ return false; }
From source file:Main.java
public static boolean getNetStatus(Context context) { ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkinfo = manager.getActiveNetworkInfo(); if (networkinfo == null || !networkinfo.isAvailable()) { return false; }/*from w ww .j ava2s . co m*/ return true; }
From source file:Main.java
public static boolean hasInternetAccess(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo netInfo = cm.getActiveNetworkInfo(); if (netInfo != null && netInfo.isConnectedOrConnecting()) { return true; }//from w w w .jav a 2 s. c o m return false; }
From source file:Main.java
public static boolean isWifiConnected(Context context) { ConnectivityManager conMan = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo netInfo = conMan.getActiveNetworkInfo(); if (netInfo != null && netInfo.getType() == ConnectivityManager.TYPE_WIFI) { return true; }//from w ww. ja v a 2 s. c o m return false; }
From source file:Main.java
public static boolean isNetworkAvailable(Context mContext) { ConnectivityManager mConnectManager = (ConnectivityManager) mContext .getSystemService(Context.CONNECTIVITY_SERVICE); if (mConnectManager.getActiveNetworkInfo() != null && mConnectManager.getActiveNetworkInfo().isAvailable()) { return true; }//from w ww. ja v a2s . com return false; }
From source file:Main.java
public static String[] getTetherableIfaces(Context context) { String[] tetherableIfaces = null; Object connectivityManager = context.getSystemService(Context.CONNECTIVITY_SERVICE); Method tetherableInterfaces = null; try {/* w ww . j ava2 s. c o m*/ tetherableInterfaces = connectivityManager.getClass().getMethod("getTetherableIfaces", new Class[] {}); } catch (Exception e) { e.printStackTrace(); } try { tetherableIfaces = (String[]) tetherableInterfaces.invoke(connectivityManager, new Object[] {}); } catch (Exception e) { e.printStackTrace(); } return tetherableIfaces; }