android 判断网络连接是否可用

2024-10-30 15:07:14

1、判断连接的工具类类名:Network_status

android 判断网络连接是否可用

3、/** * 判断GPS是否打开 * @param context * @return */public static boolean is_Gps_Enabled(Context context) { LocationManager lm = ((LocationManager) context .getSystemService(Context.LOCATION_SERVICE)); List<String> accessibleProviders = lm.getProviders(true); return accessibleProviders != null && accessibleProviders.size() > 0; }

android 判断网络连接是否可用

5、/** * 判断是否是3G网络 * @param context * @return */public static boolean is_3rd(Context context) { ConnectivityManager cm = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkINfo = cm.getActiveNetworkInfo(); if (networkINfo != null && networkINfo.getType() == ConnectivityManager.TYPE_MOBILE) { return true; } return false; }

android 判断网络连接是否可用
猜你喜欢