<span style="font-size:18px;">// 是否连接WIFI public static boolean isWifiConnected(Context context) { ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo wifiNetworkInfo = connectivityManager .getNetworkInfo(ConnectivityManager.TYPE_WIFI); if (wifiNetworkInfo.isConnected()) { return true; } return false; } /** * 对网络连接状态进行判断 * * @return true, 可用; false, 不可用 */ public static boolean isOpenNetwork(Context ctx) { ConnectivityManager connManager = (ConnectivityManager) ctx .getSystemService(Context.CONNECTIVITY_SERVICE); if (connManager.getActiveNetworkInfo() != null) { return connManager.getActiveNetworkInfo().isAvailable(); } return false; }</span>
时间: 2024-09-28 16:44:14