List of usage examples for android.net ConnectivityManager getActiveNetworkInfo
@Deprecated
@RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE)
@Nullable
public NetworkInfo getActiveNetworkInfo()
From source file:Main.java
public static boolean checkNetWork(Context context) { boolean flag = false; ConnectivityManager cwjManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); if (cwjManager.getActiveNetworkInfo() != null) flag = cwjManager.getActiveNetworkInfo().isAvailable(); return flag;/* w w w. j a v a2 s . co m*/ }
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 . ja va2 s . c om*/ return false; }
From source file:Main.java
public static boolean isOnline(Context context) { ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Activity.CONNECTIVITY_SERVICE); NetworkInfo info = manager.getActiveNetworkInfo(); if (info != null && info.isConnected()) { return true; }/*from ww w .j av a2 s .c o m*/ return false; }
From source file:Main.java
public static boolean isConnectedToInternet(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); boolean isConnected = activeNetwork != null && activeNetwork.isConnectedOrConnecting(); return isConnected; }
From source file:Main.java
public static boolean isOpenNetwork(Context context) { ConnectivityManager connManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); if (connManager.getActiveNetworkInfo() != null) { return connManager.getActiveNetworkInfo().isAvailable(); }//from ww w. j a v a2 s . c o m return false; }
From source file:Main.java
public static boolean netWorkIsEnable(Context context) { ConnectivityManager connManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); if (connManager.getActiveNetworkInfo() != null) { return connManager.getActiveNetworkInfo().isAvailable(); }/*from ww w. ja v a 2s . c o m*/ return false; }
From source file:Main.java
private static boolean isWifiContected(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo ni = cm.getActiveNetworkInfo(); return ni != null && ni.getType() == ConnectivityManager.TYPE_WIFI; }
From source file:Main.java
public static boolean isNetworkConnected(Activity activity) { ConnectivityManager cm = (ConnectivityManager) activity.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetworkInfo = cm.getActiveNetworkInfo(); return activeNetworkInfo != null && activeNetworkInfo.isConnected(); }
From source file:Main.java
public static boolean isNetworkAvailable(Context context) { ConnectivityManager connec = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo netInfo = connec.getActiveNetworkInfo(); if (netInfo != null && netInfo.isConnected() == true) { return true; }// w w w . j ava 2 s . c o m return false; }
From source file:Main.java
public static boolean checkNetwork() { boolean flag = false; ConnectivityManager cwjManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); if (cwjManager.getActiveNetworkInfo() != null) flag = cwjManager.getActiveNetworkInfo().isAvailable(); return flag;// w ww.j a va2s.c om }