2012年10月18日

Android中判断当前网络是否可用

摘要: 应用场景:实现判断当前网络是否可用当前有可用网络,如下图:当前没有可用网络,如下图:实现步骤:1、获取ConnectivityManager对象Context context = activity.getApplicationContext();// 获取手机所有连接管理对象(包括对wi-fi,net等连接的管理)ConnectivityManager connectivityManager = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);2、获取NetworkInfo对象// 获取Ne 阅读全文

posted @ 2012-10-18 17:49 Harvey Ren 阅读(52727) 评论(1) 推荐(2) 编辑

导航