首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

检察连接类型是wifi or mobile

2012-08-29 
检查连接类型是wifi or mobileConnectivityManager conMan (ConnectivityManager) getSystemService(Con

检查连接类型是wifi or mobile

ConnectivityManager conMan = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);?
?
//mobile?
State mobile = conMan.getNetworkInfo(0).getState();?
?
//wifi?
State wifi = conMan.getNetworkInfo(1).getState();?

if (mobile == NetworkInfo.State.CONNECTED || mobile == NetworkInfo.State.CONNECTING) {?
? ? //mobile?
} else if (wifi == NetworkInfo.State.CONNECTED || wifi == NetworkInfo.State.CONNECTING) {?
? ? //wifi?
}?

热点排行