『转』android 程序中判断当前是否连接网络,网络是否可用
来源:互联网 发布:炫踪网络 ceo 编辑:程序博客网 时间:2024/05/22 11:50
if(checkNetWorkStatus(getApplicationContext())){ //当前网络可用}else{ //当前网络不可用 return -1;}
public static boolean checkNetWorkStatus(Context context) { boolean result; ConnectivityManager cm = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo netinfo = cm.getActiveNetworkInfo(); if (netinfo != null && netinfo.isConnected()) { result = true; Log.i("NetStatus", "The net was connected"); } else { result = false; Log.i("NetStatus", "The net was bad!"); } return result; }
0 0
- 『转』android 程序中判断当前是否连接网络,网络是否可用
- Android中判断当前网络是否可用
- Android中判断当前网络是否可用
- Android中判断当前网络是否可用
- Android中判断当前网络是否可用
- Android中判断当前网络是否可用
- ANDROID中判断网络连接是否可用
- android中判断网络连接是否可用
- Android中判断网络连接是否可用
- android中判断网络连接是否可用
- android中判断网络连接是否可用
- android中判断网络连接是否可用
- Android判断当前网络是否可用
- Android判断当前网络是否可用
- android 判断当前网络是否可用
- 判断当前网络是否可用
- 判断当前网络是否可用
- 判断当前网络是否可用
- HDU 1080 Human Gene Functions
- Jquery中toggle的用法
- 传参出错注意数据库连接问题
- window.close and self.close do not close the window in Chrome
- C++实现24位位图的灰度化
- 『转』android 程序中判断当前是否连接网络,网络是否可用
- 利用.dSYM和.app文件准确定位Crash位置
- Android 命令行手动编译打包详解
- 如何修改 SAP 登录后的背景图片(事务码 SMW0,SM30)
- ireport+jasperreport+jfreechart完成数据分析
- Linux中ctrl+z 、ctrl+c、 ctrl+d区别
- SQL 统计语句
- 在C#的WPF程序使用XAML实现画线
- 极光推送