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 isWifi(Context context) { ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetInfo = connectivityManager.getActiveNetworkInfo(); if (activeNetInfo != null && activeNetInfo.getType() == ConnectivityManager.TYPE_WIFI) { return true; }/*from www. j a va 2s.c om*/ return false; }
From source file:Main.java
public static State getNetworkState(Context act) { ConnectivityManager cm = (ConnectivityManager) act.getSystemService(Context.CONNECTIVITY_SERVICE); if (cm == null) return null; NetworkInfo info = cm.getActiveNetworkInfo(); if (info != null) return info.getState(); return null;//www.ja v a2 s.co m }
From source file:Main.java
public static Boolean isNetworkAvailable(Context context) { ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo(); return activeNetworkInfo != null && activeNetworkInfo.isConnectedOrConnecting(); }
From source file:Main.java
public static boolean isNetworkAvailable(Context context) { ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo(); return activeNetworkInfo != null; }
From source file:Main.java
public static boolean networkUnreachable(Context cxt) { ConnectivityManager connectivityManager = (ConnectivityManager) cxt .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo(); if (null == activeNetworkInfo) { return true; }//from w w w. j a v a2 s . c om return !activeNetworkInfo.isConnected(); }
From source file:Main.java
public static boolean isConnected(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo ni = cm.getActiveNetworkInfo(); return ni != null && ni.isConnectedOrConnecting(); }
From source file:Main.java
public static boolean isNetworkConnected(Context context) { try {//ww w . j a v a 2 s . com NetworkInfo networkInfo = ((ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE)) .getActiveNetworkInfo(); return networkInfo != null && networkInfo.isConnected(); } catch (NullPointerException e) { e.printStackTrace(); return false; } }
From source file:Main.java
public static boolean isNetworkAvailable(Context context) { ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo(); return activeNetworkInfo != null && activeNetworkInfo.isConnectedOrConnecting(); }
From source file:Main.java
public static boolean checkNetWork(Context context) { boolean newWorkOK = false; ConnectivityManager connectManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); if (connectManager.getActiveNetworkInfo() != null) { newWorkOK = true;// w ww. j a va2 s .c om } return newWorkOK; }
From source file:Main.java
public static boolean networkCanUse(Context context) { ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo netinfo = connectivityManager.getActiveNetworkInfo(); if (netinfo != null && netinfo.isConnected()) { return true; }/*from w w w.jav a2s .c o m*/ return false; }