public static boolean isNetWorkDataAvailable(final Context context) { Runtime runtime = Runtime.getRuntime(); try { Process pingProcess = runtime.exec("/system/bin/ping -c 1 www.baidu.com"); int exitCode = pingProcess.waitFor(); return (exitCode == 0); } catch (Exception e) { e.printStackTrace(); } return false; }
检查网络是否可用
最新推荐文章于 2021-05-27 00:20:15 发布