判断wifi网络是否链接:
| 代码如下 | 复制代码 |
publicstaticbooleanisWiFiActive(Context inContext) { WifiManager mWifiManager = (WifiManager) inContext .getSystemService(Context.WIFI_SERVICE); WifiInfo wifiInfo = mWifiManager.getConnectionInfo(); intipAddress = wifiInfo ==null?0: wifiInfo.getIpAddress(); if(mWifiManager.isWifiEnabled() && ipAddress !=0) { System.out.println("**** WIFI is on"); returntrue; }else{ System.out.println("**** WIFI is off"); returnfalse; } } | |
判断3G网络是否链接:
| 代码如下 | 复制代码 |
publicstaticbooleanisNetworkAvailable( Context context) { ConnectivityManager connectivity = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); if(connectivity ==null) { System.out.println("**** newwork is off"); returnfalse; }else{ NetworkInfo info = connectivity.getActiveNetworkInfo(); if(info ==null){ System.out.println("**** newwork is off"); returnfalse; }else{ if(info.isAvailable()){ System.out.println("**** newwork is on"); returntrue; } } } System.out.println("**** newwork is off"); returnfalse; } | |
相关权限:
| 代码如下 | 复制代码 |
SQL SERVER 2008 R2配置管理器出现“远程过程调用失败”(0x800706be)错误提示实用指南
《摩尔庄园手游》11月2日神奇密码汇总 礼包码口令最新11月2日
热血江湖归来手游攻略大全 热血江湖归来玩法详细说明
热血江湖归来刀客如何玩 热血江湖归来刀客技能加点推荐
热血江湖归来坐骑系统分享 热血江湖归来坐骑获取与培养操作步骤
SqlServer2008 数据库同步的两种方式(发布、订阅使用做法)实用指南